OpenFile()

Syntax

Result = OpenFile(#File, FileName$)
Description
It will open the designed file or create it if it doesn't exists. Read and write can be performed on this file. OpenFile() will be used the same way like the "read-only" ReadFile() and the "write-only" CreateFile() commands.

If #PB_Any is used as '#File' parameter, the new file number will be returned as 'Result'.

If 'Result' is not 0, the file is effectively opened, else the file can't be opened. It must be always tested, as performing operations on a non opened file will cause severe crashs.

If the #File was already used, the previous file is automatically closed.

Note: when using OpenFile() the file must have the rights for reading AND writing. For example, this can be a problem to manipulate a file on a cdrom. To read from a file, better use ReadFile() instead.

Supported OS

All

<- Lof() - File Index - ReadByte() ->