var
sl1, sl2: TStrings;
i,j: Integer;
sTemp: String;
s1,s2 :string;
begin
sl1 := TStringList.Create;
try
sl1.LoadFromFile('c:\cxbb\txt\1.txt');
for i := (sl1.Count - 1) downto 0 do
begin
sTemp := sl1.Strings[i];
s1:=copy(stemp,53,2);
j:=strtoint(s1);
if j<2 then begin
sl1[i]:='';
end;
end;
sl1.SaveToFile('c:\cxbb\txt\all.txt');
finally
sl1.Free;
end;
end;
既想要把文本从53列开始取2个字节,如果这2个字节的值小于2的时候就把这行删除,为什么编译的时候老出错!
sl1, sl2: TStrings;
i,j: Integer;
sTemp: String;
s1,s2 :string;
begin
sl1 := TStringList.Create;
try
sl1.LoadFromFile('c:\cxbb\txt\1.txt');
for i := (sl1.Count - 1) downto 0 do
begin
sTemp := sl1.Strings[i];
s1:=copy(stemp,53,2);
j:=strtoint(s1);
if j<2 then begin
sl1[i]:='';
end;
end;
sl1.SaveToFile('c:\cxbb\txt\all.txt');
finally
sl1.Free;
end;
end;
既想要把文本从53列开始取2个字节,如果这2个字节的值小于2的时候就把这行删除,为什么编译的时候老出错!
sl1, sl2: TStrings;
i,j: Integer;
sTemp: String;
s1,s2 :string;
begin
sl1 := TStringList.Create;
sl1.LoadFromFile('c:\cxbb\txt\1.txt');
for i:=0 to pred(sl1.Count) do
// for i:=0 to 8 do
begin
sTemp := sl1.Strings[i];
s1:=copy(stemp,54,1);
// showmessage(s1);
// j:=strtoint(s1); if s1=' ' then
sl1.Delete(i);
delete
end;
// sl1.SaveToFile('c:\cxbb\txt\all.txt');
sl1.Free;
end;
如果54列的值是 ‘’那么就删除这行为什么错误!
ERROR LIST INDEX OUT OF 1269 是什么原因!
sl1, sl2: TStrings;
i,j: Integer;
sTemp: String;
s1,s2 :string;
begin
sl1 := TStringList.Create;
try
sl1.LoadFromFile('c:\cxbb\txt\1.txt');
while i=sl1.count do
begin
sTemp := sl1.Strings[i];
s1:=copy(stemp,54,1);
if s1<>' ' then
inc(i)
else
sl1.Delete(i);
end;
sl1.SaveToFile('c:\cxbb\txt\all.txt');
finally
sl1.Free;
end;
end;
while i=sl1.count do
改为 while i<sl1.count do