| %MEMXCPY | Index Level | %PAUSE |
| Syntax | file.descriptor = %OPEN( string, oflag {, mode} ) |
| Category | BASIC |
| Type | C Function |
| Description |
opens the Unix file specified by "string" and sets the file status flags according to the value of "oflag".
Files opened by %open() are closed automatically when the FlashBASIC programs terminates. Valid values of "oflag" are defined in the include fcntl.h. Combinations of the modes are obtained by adding several flags together from the following list: O$RDONLY Opens for reading only. O$WRONLY Opens for writing only. O$RDWR Opens for reading and writing. O$NDELAY Non blocking I/O. The effect of this flag varies depending on the type of the file. See the Unix Programmer's Reference Manual. O$APPEND Moves the file pointer to the end of the file. O$SYNC Sync writes. O$CREAT If the file exists, this flag has no effect. Otherwise, owner ID and group ID are set and the mode of the file is set according to the value of mode modified as follows: all bits in the file mode creation mask of the process are cleared and the sticky bit is cleared. O$TRUNC If the file exists, its length is set 0. O$EXCL If O$EXCL and O$CREAT are set, open will fail if the file exists. The file descriptor is returned as a number or "-1" if an error occurred. System(0) contains the error number. |
| Options | |
| See Also | c function %CLOSE %READ (D3/Unix) %WRITE (D3/Unix) %WHEX %RDHEX CFUNCTION %TTYNAME %UNLINK %FSIZE %LSEEK (D3/Unix) |
| Example |
include dm,bp,unix.h fcntl.h
fd=%open( '/usr/pick/fname', O$WRONLY+O$APPEND ) if fd<0 then crt 'Cannot open. errno=':system(0) end |
| Warnings |
There is a limit on the number of Unix files a process may have opened simultaneously. See the Unix System Administrator guide.
Files opened by a FlashBASIC program are normally closed automatically when the program terminates. However, it is a good practice to close them. |
| Compatibility | D3/Unix |
| %MEMXCPY | Index Level | %PAUSE |