如何在文本文件里进行自动换行(200分)

  • 主题发起人 主题发起人 rainboy5906
  • 开始时间 开始时间
R

rainboy5906

Unregistered / Unconfirmed
GUEST, unregistred user!
var
aa,bb,cc:integer;
F:TFileStream;
mystr,mystr1,mystr2:string;
str1,str2,str3,str4,str5,str6,str7:string;
str8,str9,str10,str12,str13,str14:string;
str15,str16,str17,str18,str19,str21:string;
str22,str23:string;
bstr:string;
ws1,ws2,ws3,ws4,ws5,ws6,ws7,ws8,ws9,ws10,ws11,ws12,ws13,ws14:string;
ws15,ws16,ws17,ws18,ws19,ws20,ws21,ws22,ws23:string;
begin
with f_dm do
begin
q_1.close;
q_1.sql.clear;
q_1.sql.add('select * from bkwt_z');
q_1.open;

q_1.First;

bstr:=copy(q_1.fieldbyname('文件生成日期').Value,5,4);

F:=TFileStream.create('C:/一卡通系统/in/'+'ACT'+bstr+'.USR',fmcreate);
F.Seek(0, soFromBeginning);

while not q_1.Eof do
begin
If f_dm.q_1.Fieldbyname('记录标识').Value<>Null then
begin
str1:='UAT';
end
else
begin
str1:='UAT';
end;

If f_dm.q_1.Fieldbyname('产生文件的机构代号').Value<>NULL then
begin
ws2:=q_1.Fieldbyname('产生文件的机构代号').Value;
str2:=copy('000000',1,6-length(ws2))+ws2;
end
else
begin
str2:='602007';
end;

If f_dm.q_1.Fieldbyname('文件生成日期').Value<>Null then
begin
ws3:=f_dm.q_1.Fieldbyname('文件生成日期').Value;
str3:=copy('00000000',1,8-length(ws3))+ws3;
end
else
begin
str3:=FormatDateTime('YYYYmmdd',Date());
end;

If f_dm.q_1.Fieldbyname('撤销委托回答记录数').Value<>Null then
begin
ws4:=f_dm.q_1.Fieldbyname('撤销委托回答记录数').Value;
str4:=copy('0000000000',1,10-length(ws4))+ws4;
end
else
begin
str4:='0000000000';
end;

If f_dm.q_1.Fieldbyname('授权委托回答记录数').Value<>Null then
begin
ws5:=f_dm.q_1.Fieldbyname('授权委托回答记录数').Value;
str5:=copy('0000000000',1,10-length(ws5))+ws5;
end
else
begin
str5:='0000000000';
end;

mystr:=str1+str2+str3+str4+str5+#10#13;
F.WriteBuffer(mystr[1],length(mystr));

q_2.close;
q_2.sql.clear;
q_2.sql.add('select * from bkwt_c where 总记录标识=:zjl ');
q_2.parameters.parambyname('zjl').value:=q_1.fieldbyname('总记录标识').value;
q_2.open;

while not q_2.Eof do
begin
If f_dm.q_2.Fieldbyname('记录标识').Value<>Null then
begin
str6:='UAD';
end
else
begin
str6:='UAD';
end;

If q_2.FieldByName('受理机构代号').Value<>NULL then
begin
ws7:=q_2.FieldByName('受理机构代号').Value;
str7:=copy('000000',1,6-length(ws7))+ws7;
end
else
begin
str7:='000000';
end;

If f_dm.q_2.Fieldbyname('系统跟踪号').Value<>Null then
begin
ws8:=f_dm.q_2.Fieldbyname('系统跟踪号').Value;
str8:=copy('00000000',1,8-length(ws8))+ws8;
end
else
begin
str8:='00000000';
end;

If f_dm.q_2.Fieldbyname('申请日期').Value<>Null then
begin
ws9:=f_dm.q_2.Fieldbyname('申请日期').Value;
str9:=copy('00000000',1,8-length(ws9))+ws9;
end
else
begin
str9:='00000000';
end;

If f_dm.q_2.Fieldbyname('银行卡号').Value<>Null then
begin
ws10:=f_dm.q_2.Fieldbyname('银行卡号').Value;
str10:=copy('0000000000000000000',1,19-length(ws10))+ws10;
end
else
begin
str10:='0000000000000000000';
end;

If f_dm.q_2.Fieldbyname('委托项目代号').Value<>Null then
begin
ws12:=f_dm.q_2.Fieldbyname('委托项目代号').Value;
str12:=copy('000000',1,6-length(ws12))+ws12;
end
else
begin
str12:='000000';
end;

If f_dm.q_2.Fieldbyname('委托项目用户号').Value<>Null then
begin
ws13:=trim(f_dm.q_2.Fieldbyname('委托项目用户号').Value);
str13:=copy('00000000',1,8-length(ws13))+ws13+#32#32;
end
else
begin
str13:='00000000'+#32#32;
end;

If f_dm.q_2.Fieldbyname('处理结果').Value<>Null then
begin
ws14:=f_dm.q_2.Fieldbyname('处理结果').Value;
str14:=copy('00',1,2-length(ws14))+ws14;
end
else
begin
str14:='00';
end;

q_2.next;
mystr1:=str6+str7+str8+str9+str10+str12+str13+str14+#10#13;
F.WriteBuffer(mystr1[1],length(mystr1));
end;

q_3.close;
q_3.sql.clear;
q_3.sql.add('select * from bkwt_s where 总记录标识=:zjll');
q_3.parameters.parambyname('zjll').value:=q_1.fieldbyname('总记录标识').value;
q_3.open;
while not q_3.Eof do
begin
str15:='UAA';

If q_3.FieldByName('受理机构代号').Value<>Null then
begin
ws16:=q_3.FieldByName('受理机构代号').Value;
str16:=copy('000000',1,6-length(ws16))+ws16;
end
else
begin
ws16:='000000';
end;

If f_dm.q_3.Fieldbyname('系统跟踪号').Value<>Null then
begin
ws17:=f_dm.q_3.Fieldbyname('系统跟踪号').Value;
str17:=copy('00000000',1,8-length(ws17))+ws17;
end
else
begin
str17:='00000000';
end;

If f_dm.q_3.Fieldbyname('申请日期').Value<>Null then
begin
ws18:=f_dm.q_3.Fieldbyname('申请日期').Value;
str18:=copy('00000000',1,8-length(ws18))+ws18;
end
else
begin
str18:='00000000';
end;

If f_dm.q_3.Fieldbyname('银行卡号').Value<>Null then
begin
ws19:=f_dm.q_3.Fieldbyname('银行卡号').Value;
str19:=copy('0000000000000000000',1,19-length(ws19))+ws19;
end
else
begin
str19:='0000000000000000000';
end;


If f_dm.q_3.Fieldbyname('委托项目代号').Value<>Null then
begin
ws21:=f_dm.q_3.Fieldbyname('委托项目代号').Value;
str21:=copy('000000',1,6-length(ws21))+ws21;
end
else
begin
str21:='000000';
end;

If f_dm.q_3.Fieldbyname('委托项目用户号').Value<>Null then
begin
ws22:=trim(f_dm.q_3.Fieldbyname('委托项目用户号').Value);
str22:=copy('00000000',1,8-length(ws22))+ws22+#32#32;
end
else
begin
str22:='00000000'+#32#32;
end;

If f_dm.q_3.Fieldbyname('处理结果').Value<>Null then
begin
ws23:=f_dm.q_3.Fieldbyname('处理结果').Value;
str23:=copy('00',1,2-length(ws23))+ws23;
end
else
begin
str23:='00';
end;

q_3.next;
mystr2:=str15+str16+str17+str18+str19+str21+str22+str23+#10#13;

F.WriteBuffer(mystr2[1],length(mystr2));
end;
q_1.next;
end;

end;
F.Free;
showmessage('生成用户委托申请回答文件成功!');
end;

procedure Tf_main.ToolButton113Click(Sender: TObject);
begin
ToolButton65.Click;
end;


我想在文本文件里实现自动换行,但就是实现不了,都是在处在第一行上,请问各位GGDDJJMM们,这个问题该如何解决?!!急!!!
 
用f:filetext;
readln
writeln
不行吗
 
mystr1:=str6+str7+str8+str9+str10+str12+str13+str14+#10#13;
改成
mystr1:=str6+str7+str8+str9+str10+str12+str13+str14+#13#10;
 
从dos到windows,回车用两个asiic字符表示,就是 #13 #10 ,一定要按照这样的顺序。
 
多人接受答案了。
 
后退
顶部