Link to home
Start Free TrialLog in
Avatar of K Feening
K FeeningFlag for Australia

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
Avatar of Geert G
Geert G
Flag of Belgium image

only use the write instead of writeln
the file ends with #26
Avatar of K Feening

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
#26 is the End Of File marker

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;

Open in new window

I copied and pasted the code you sent me and the file was created by with noting in it - no records
Testline1 or 2
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for you help I will try this on site should be ok i hope
thanks again