K Feening
asked on
Using Writeln to create text file in delphi
I am using Writeln for create a text file in delphi 5 and packing it to 628 charactors
The writeln option adds a CRLF at the end of each line (as far as I have read)
error .. On some computers the last line looses the CRLF
txtline := 'Testline1';
l := length(txtline)
for i := l to 628 do begin
txtline := txtline + ' ';
end;
txtline := 'Testline2';
l := length(txtline)
for i := l to 628 do begin
txtline := txtline + ' ';
end;
any suggestions how I can fix this
The writeln option adds a CRLF at the end of each line (as far as I have read)
error .. On some computers the last line looses the CRLF
txtline := 'Testline1';
l := length(txtline)
for i := l to 628 do begin
txtline := txtline + ' ';
end;
txtline := 'Testline2';
l := length(txtline)
for i := l to 628 do begin
txtline := txtline + ' ';
end;
any suggestions how I can fix this
ASKER
Thanks
But the file has to end with - CRLF #13#10 or the government department wont accept it
I am not sure what #26 is
But the file has to end with - CRLF #13#10 or the government department wont accept it
I am not sure what #26 is
#26 is the End Of File marker
did you try the TStringList approach ?
and the format routine ?
did you try the TStringList approach ?
and the format routine ?
procedure CreateGovFile(FileName: string);
var List: TStrings;
begin
List := TStringList.Create;
try
List.Add(Format('%-628.s', ['TestLine1']));
List.Add(Format('%-628.s', ['TestLine2']));
List.SaveToFile(FileName);
finally
FreeAndNil(List);
end;
end;
ASKER
I copied and pasted the code you sent me and the file was created by with noting in it - no records
Testline1 or 2
Testline1 or 2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for you help I will try this on site should be ok i hope
thanks again
thanks again
the file ends with #26