Difference between revisions of "RewriteFile"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> function RewriteFile(Path: string; Shared: Boolean): Integer; </source> ==Availability== SCAR Divi 3.00 > Current ==Descriptio...")
 
(Description)
Line 8: Line 8:
  
 
==Description==
 
==Description==
Opens a file specified by '''Path''' for writing access. If the path name is valid it will return the handle of the file stream to the file in the files resource manager, if not, it raises an exception. If '''Shared''' is [[true]], the file can be accessed by other processes while it is in use by SCAR Divi, if it is [[false]] the script gets exclusive access until [[CloseFile]] is used to close the file stream.
+
Opens a file specified by '''Path''' for writing access. If the path name is valid it will return the handle of the file stream to the file in the files resource manager, if not, it raises an exception. If '''Shared''' is [[true]], the file can be accessed by other processes while it is in use by SCAR Divi, if it is [[false]] the script gets exclusive access until [[CloseFile]] is used to close the file stream. If you wish to read a file, you can use the [[OpenFile]] function.
  
 
==Example==
 
==Example==

Revision as of 09:32, 1 July 2011

Definition

function RewriteFile(Path: string; Shared: Boolean): Integer;

Availability

SCAR Divi 3.00 > Current

Description

Opens a file specified by Path for writing access. If the path name is valid it will return the handle of the file stream to the file in the files resource manager, if not, it raises an exception. If Shared is true, the file can be accessed by other processes while it is in use by SCAR Divi, if it is false the script gets exclusive access until CloseFile is used to close the file stream. If you wish to read a file, you can use the OpenFile function.

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.

See Also