This function creates a new file. Under Windows the file is opened with mode 66
Y is 0 or a negative integer value that specifies an (unused) tie number by which the file may subsequently be referred. If Y is 0, the system allocates the first (closest to zero) available tie number which is returned as the result.
The shy result of ⎕NCREATE is the tie number of the new file.
⎕NCREATE may be applied using the Variant operator with the options Unique and IfExists. There is no primary option.
0 | the file named by X will be created |
1 | a uniquely named file will be created by extending the base name (see File Name Parts) with random characters. If a unique name cannot be created then an error will be signalled. The actual name of the file can be determined from ⎕NNAMES or ⎕NINFO. |
Error | ⎕NCREATE will generate a FILE NAME ERROR if the file already exists |
Replace | ⎕NCREATE will replace an existing file with an empty one of the same name. |
⊢'myfile' ⎕NCREATE 0 ¯1 ⎕NUNTIE ¯1 ⊢'myfile' ⎕NCREATE 0 FILE NAME ERROR: myfile: Unable to create file ("The file exists.") ⊢'myfile'⎕NCREATE 0 ∧
⊢'myfile' (⎕NCREATE⍠'IfExists' 'Replace') 0
¯1 ⍝ Note that it uses same tie number as before
⊢'myfile' (⎕NCREATE⍠('Unique' 1)) 0 ¯2 ⎕NNUMS,⎕NNAMES ¯1 myfile ¯2 myfile52c36z