SystemSeekEof (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example creates a file, TEST.TXT, puts text in it, and then reads the file to EOF.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
   f : System.TextFile;
   j, Y : Integer;
 begin
   AssignFile(f,'TEST.TXT');
   Rewrite(f);
   { Create a file with eight numbers and an amount of
     whitespace at the ends of the lines. }
   Writeln(f,'1 2 3 4 ');
   Writeln(f,'5 6 7 8 ');
   Reset(f);
   { Read the numbers back. SeekEof returns True if there is no 
     more text--other than whitespace--in the file. }
   Y := 5;
   while not SeekEof(f) do
   begin
     Read(f,j);
     Canvas.TextOut(5, Y, IntToStr(j));
     Y := Y + Canvas.TextHeight(IntToStr(j)) + 5;
   end;
 end;

Uses

Personal tools
Assistance