Difference between revisions of "ReadFileString"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> function ReadFileString(FileNum: Integer; var s: string; Length: Integer): Boolean; </source> ==Availability== SCAR Divi 3.00 >...")
 
(No difference)

Latest revision as of 14:27, 4 July 2011

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