[id] = OpenFile(id, filename$[, mode, table])
idto it. If you pass Nil in
OpenFile()will automatically choose a vacant identifier and return it. If the file does not exist, this function will fail unless you use the
modeargument to open a file for writing. In that case,
OpenFile()will create the file for you.
All read and write operations will start at the current file cursor position. You can manually set the file cursor by using the Seek() function but it is also increased if you use other functions which read from or write to the file.
Starting with Hollywood 2.0 you can use the optional argument
open the file in read (default) or write mode or in shared mode, which
means that you can read from the file and you can also write to it. If
a file is opened in read mode, all write operations will fail. If a file
is opened in write mode, all read operations will fail.
Starting with Hollywood 6.0 this function accepts an optional table argument which can be used to pass additional parameters. The following table elements are currently recognized:
default. See Loaders and adapters for details. (V6.0)
Although Hollywood will automatically close all open files when it quits, it is strongly advised that you close an open file when you are done with it using the CloseFile() function so that it becomes available to the operating system again.
This command is also available from the preprocessor: Use @FILE to preopen files!
OpenFile(1, "Highscores.txt") While Not Eof(1) Do NPrint(ReadLine(1)) CloseFile(1)This code opens the file "Highscores.txt" as file 1 and prints all of its lines to the screen.