Solved

Using Writeln to create text file in delphi

Posted on 2008-06-25
6
3,138 Views
Last Modified: 2013-11-23
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
0
Comment
Question by:Kevinfeening
  • 3
  • 3
6 Comments
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 21871957
only use the write instead of writeln
the file ends with #26
0
 

Author Comment

by:Kevinfeening
ID: 21871998
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
0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 21872106
#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

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:Kevinfeening
ID: 21872305
I copied and pasted the code you sent me and the file was created by with noting in it - no records
Testline1 or 2
0
 
LVL 36

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 21872361
silly points ...
procedure CreateGovFile(FileName: string);

var List: TStrings;

begin

  List := TStringList.Create;

  try

    List.Add(Format('%-628s', ['TestLine1']));

    List.Add(Format('%-628s', ['TestLine2']));

    List.SaveToFile(FileName);

  finally

    FreeAndNil(List); 

  end;

end;

Open in new window

0
 

Author Closing Comment

by:Kevinfeening
ID: 31470863
Thanks for you help I will try this on site should be ok i hope
thanks again
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now