关于文件的生成问题?
无聊的小船 2003-10-22 09:27:09 我想将生的文件内容排列成以下顺序
1 abc 10
2 abc 20
12 abcd 20
111 ab 123
不知道我下面的这段代码怎么修改
procedure TfrmUStu.btnOutClick(Sender: TObject);
var
Present: TDateTime;
Year,Month,Day: Word;
SL: TStringlist;
lp: integer;
StrTmp,str,filename: string;
begin
Present:=Now;
DecodeDate(Present,Year,Month,Day);
filename := 'E:\jlj\stutdata\'+formatfloat('00',Month)+formatfloat('00',Day){copy(datetostr(now),1,2)+copy(datetostr(now),4,2)}+
stringreplace(timetostr(now),':','',([rfReplaceAll]))+'.txt';
SL := TStringlist.Create;
try
cdsStut.first;
while not cdsStut.eof do
begin
StrTmp := '';
for lp :=0 to cdsStut.Fields.Count-2 do //cdsStut是ClientDataset
StrTmp := StrTmp + cdsStut.Fields[lp].Asstring +'';
SL.Add(StrTmp);
cdsStut.next;
end;
SL.SaveToFile(filename);
showmessage('已生成文件'+filename);
finally
SL.free;
end;
end;