FOpen

number FOpen(string name, number mode)

Opens the file with the specified mode. Upon success, it returns a handle to the file, otherwise, it returns NULL.

The modes are as follows:

fOPENFAIL open or fail: Try to open file, abort if not possible
fOPENCREATE open or create: Try to open file, create it if it doesn't exist
fCREATE create: Create the file, destroying any content it might have had
Example
(var hFile, buffer[41])

// Open the file and write to it
(if( <> NULL (= hFile FOpen("somefile.txt" fCREATE)) )
    FPuts(hFile "Hello World!")
    FClose(hFile)
)

// Open the file, read it's first string, and print it to the screen
(if( <> NULL (= hFile FOpen("somefile.txt" fOPENFAIL)) )
    FGets(buffer 40 hFile)
    FClose(hFile)

    Print(buffer)
)

See Also: FClose, FGets, FPuts