%CREAT

%CREAT


%CONNECT Index Level %DUP
Syntax file.descriptor = %CREAT( string, mode )
Category BASIC
Type C Function
Description creates a new ordinary Unix file or prepares to rewrite an existing Unix file designated by "string" for write only. "mode" controls the file mode. Valid values of "mode" are in the include "mode.h". Combinations of the modes are obtained by adding several elementary modes together.
Options
See Also %READ (D3/Unix) %WRITE (D3/Unix) c function CFUNCTION %WHEX %RDHEX %CLOSE %UNLINK %FSIZE
Example include dm,bp,unix.h mode.h

* Create a unique temporary file
* read and write permission for user,
* read for group
fd=%creat( "/tmp/":system(19),
             S$IRUSR+S$IWUSR+S$IRGRP)

Note the usage of the plus operator to combine flags, where a regular C program would have used an 'or'.
Warnings On D3, files are closed automatically when the FlashBASIC program terminates.
Compatibility D3/Unix
%CONNECT Index Level %DUP