ReadFileString

From SCAR Divi Manual
Jump to: navigation, search

Definition

function ReadFileString(FileNum: Integer; var s: string; Length: Integer): Boolean;

Availability

SCAR Divi 3.00 > Current

Description

Reads a string from an open file stream associated with the index FileNum in the file stream resource manager and returns it in s. The length of the string you want to read has to be specified in Length. Returns false if the reading failed or the index FileNum is invalid. The file stream should have been created with OpenFile.

Example

var
  f: Integer;
  s: string;

begin
  f := Rewritefile(LogsPath + 'Test.txt', False);
  WriteFileString(f, 'Hello World!');
  CloseFile(f);

  f := OpenFile(LogsPath + 'Test.txt', False);
  ReadFileString(f, s, FileSize(f));
  WriteLn(s);
  CloseFile(f);

  DeleteFile(LogsPath + 'Test.txt');
end.

Output:

Hello World!

See Also