运行老是出错,说文件正被另一个程序调用,帮我看看错在那里。
procedure TForm1.Button1Click(Sender: TObject);
var
F:textfile;
S:string;
totalrow,myrow,i:integer;
str:tstringlist;
begin
assignfile(F,'yc.txt');
reset(F);
str:=tstringlist.Create ;
readln(F,S);
totalrow:=1;
repeat
inc(totalrow);
readln(F);
until eof(F);
reset(F);
for myrow:=0 to totalrow do
begin
readln(F,S);
str.CommaText:=S;
for i := 0 to Str.Count-2 do
begin
if i=0 then
str[i]:=MidStr(S,9,2)
else
begin
if str[i]='借' then
str[i]:='J'
else str[i]:='D';
end; str.SaveToFile('yc.txt');
end;
end;
end;
end.
procedure TForm1.Button1Click(Sender: TObject);
var
F:textfile;
S:string;
totalrow,myrow,i:integer;
str:tstringlist;
begin
assignfile(F,'yc.txt');
reset(F);
str:=tstringlist.Create ;
readln(F,S);
totalrow:=1;
repeat
inc(totalrow);
readln(F);
until eof(F);
reset(F);
for myrow:=0 to totalrow do
begin
readln(F,S);
str.CommaText:=S;
for i := 0 to Str.Count-2 do
begin
if i=0 then
str[i]:=MidStr(S,9,2)
else
begin
if str[i]='借' then
str[i]:='J'
else str[i]:='D';
end; str.SaveToFile('yc.txt');
end;
end;
end;
end.
...
reset(F);
...
finally
closefile(F);
end;
谢谢
lst := TStringList.create;
lst.loadfromfile('yc.txt'); 多方便,为啥要费这牛劲!