How to create a text file and Write/Append text into the file
// TextFile is File object
// OutStreamObj is OutStream object
// CR and LF are Char trype
TextFile.CREATE( ‘C:\TextOutput.txt’); // To Create
TextFile.CREATEOUTSTREAM(OutStreamObj);
OutStreamObj.WRITETEXT (’1st Line’); // To write into the created text file
OutStreamObj.WRITETEXT (’This is not the second line of text to be outputed but to concatenate with the first line’);
OutStreamObj.WRITETEXT(); // This command is to move to next line
OutStreamObj.WRITETEXT(’2nd Line’) ;
TextFile.Close; // To end the writing and write out to the file.
// To Append text at the end of text file
TextFile.TEXTMODE := TRUE;
TextFile.WRITEMODE := TRUE;
TextFile.OPEN(’C:\TextOutput.txt’);
TextFile.SEEK(TextFile.LEN);
TextFile.WRITE(’2nd Line end’);
TextFile.CLOSE;
// To Append text in new line of text file
CR := 10;
LF := 13;
TextFile.TEXTMODE := TRUE;
TextFile.WRITEMODE := TRUE;
TextFile.OPEN(’C:\TextOutput.txt’);
TextFile.SEEK(TextFile.LEN);
TextFile.WRITE(CR);
//OR
TextFile.WRITE(LF);
TextFile.WRITE(’3rd Line’);
TextFile.CLOSE;
Tags: Text File
January 25th, 2013 at 1:58 am
World Of Online E-books…
[…]Mohana’s Dynamics Blog » Blog Archive » How to create a text file and Write/Append text into the file[…]…
January 29th, 2013 at 6:26 pm
Why should you head to College…
[…]Mohana’s Dynamics Blog » Blog Archive » How to create a text file and Write/Append text into the file[…]…