SmartPascal
Reset
Procedure
Open a text file for reading, or binary file for read/write System unit
1  procedure Reset ( var FileHandle : TextFile ) ;
2  procedure Reset ( var FileHandle : File {RecordSize ) ;
Description
The Reset procedure opens a file given by FileHandle for read, write or read and write access.
 
You must use AssignFile to assign a file to the FileHandle before using Reset.
 
Use Write or WriteLn to write to the file after this Reset is executed.
 
Version 1
 
Is used for text files. They can only be read after opening with Reset.
 
Version 2
 
Is for binary files. Before using Reset, you must set FileMode to one of the following:
 
fmOpenRead  : Read only
fmOpenWrite  : Write only
fmOpenReadWrite  : Read and write

 
The optional RecordSize value is used to override the default 128 byte record size for binary (untyped) files. For such files, only BlockRead and BlockWrite can be used.
Related commands
Append Open a text file to allow appending of text to the end
AssignFile Assigns a file handle to a binary or text file
CloseFile Closes an open file
File Defines a typed or untyped file
ReWrite Open a text or binary file for write access
TextFile Declares a file type for storing lines of text
 
Example code : Writing and reading lines of text to/from a text file
var
  myFile : TextFile;
  text   : string;

begin
  // Try to open the Test.txt file for writing to
  AssignFile(myFile, 'Test.txt');
  ReWrite(myFile);

  // Write a couple of well known words to this file
  WriteLn(myFile, 'Hello');
  WriteLn(myFile, 'World');

  // Close the file
  CloseFile(myFile);

  // Reopen the file in read only mode
  FileMode := fmOpenRead;
  Reset(myFile);

  // Display the file contents
  while not Eof(myFile) do
  begin
    ReadLn(myFile, text);
    ShowMessage(text);
  end;

  // Close the file for the last time
  CloseFile(myFile);
end;
Show full unit code
   Hello
   World