保存为: Str=27,p,60,255读取时: function GetStr(Str:String):String; var ilist:TStrings; i,iv:integer; S:String; begin ilist:=TListString.Create; Result:=''; try ilist.Items.CommaText:=Str; for i:=0 to ilist.Items.Count-1 do if TryStrToInt(ilist.Items.Strings[i],iv) then Result:=Result+Chr(iv) else Result:=Result+ilist.Items.Strings[i]; finally ilist.Free; end; end;
保存为: Str=27,p,60,255读取时:(刚才写错了应该如下) function GetStr(Str:String):String; var ilist:TStrings; i,iv:integer; S:String; begin ilist:=TListString.Create; Result:=''; try ilist.CommaText:=Str; for i:=0 to ilist.Count-1 do if TryStrToInt(ilist.Strings[i],iv) then Result:=Result+Chr(iv) else Result:=Result+ilist.Strings[i]; finally ilist.Free; end; end;
'Chr(27)+'p'+Chr(0)+Chr(60)+Chr(255)'
其实你只要存为 '^27!p^0^60^255'
然后你判断^后面的字符加CHR
你再想想看
Str=27,p,60,255读取时:
function GetStr(Str:String):String;
var ilist:TStrings;
i,iv:integer;
S:String;
begin
ilist:=TListString.Create;
Result:='';
try
ilist.Items.CommaText:=Str;
for i:=0 to ilist.Items.Count-1 do
if TryStrToInt(ilist.Items.Strings[i],iv) then Result:=Result+Chr(iv)
else Result:=Result+ilist.Items.Strings[i];
finally
ilist.Free;
end;
end;
Str=27,p,60,255读取时:(刚才写错了应该如下)
function GetStr(Str:String):String;
var ilist:TStrings;
i,iv:integer;
S:String;
begin
ilist:=TListString.Create;
Result:='';
try
ilist.CommaText:=Str;
for i:=0 to ilist.Count-1 do
if TryStrToInt(ilist.Strings[i],iv) then Result:=Result+Chr(iv)
else Result:=Result+ilist.Strings[i];
finally
ilist.Free;
end;
end;