fileopen

Opens a file.

fileopen <file handle> <filename> <append flag> [<readonly flag>]

Parameters

integer variable <file handle>
If the file is successfully opened, the file handle is returned in this variable.
version 4.101 or earlier, and 4.104 or later: Otherwise, <file handle> is set to -1. The macro error does not cause.
version 4.102 and 4.103: Otherwise, <file handle> is set to -1. The macro script is halted after the macro eror causes.
string <filename>
Specify an opened file name
If the file does not exist, it is created and then opened.
integer <append flag>
If this parameter is zero, the file pointer is set to the beginning of the file.
If this parameter is nonzero, the file pointer is set to the end of the file.
integer <readonly flag> (optional default=0) (version 4.85 or later)
If this parameter is zero, it requests opening the file read/write.
If this parameter is nonzero, it requests opening the file read-only.

Remarks

The file is opened in the binary mode.

Example

fileopen fhandle 'data.dat' 0
fileopen fhandle 'data.dat' 1
fileopen fhandle 'test.bat' 0
filewrite fhandle 'md .\v20080619_Test'
fileclose fhandle
pause 5
exec 'cmd /c test.bat'
pause 10
end

See also