# 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.
  Otherwise, <file handle> is set to -1.
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

- filewrite
- fileclose