A function which opens a file for writing and returns the handle of the file. This number must be used in subsequent references to the file with BPUT#, PRINT#, EXT#, PTR# or CLOSE#. If the specified file does not exist it is created. If the specified file already exists it is truncated to zero length.
A returned value of zero indicates that the specified file could not be created.
X=OPENOUT(A$) X=OPENOUT("DATAFILE") X=OPENOUT("LPT1")
You can also read from a file which has been opened using OPENOUT. This is of little use until you have written some data to it. However, once you have done so, you can move around the file using PTR# and read back previously written data.
Data is not written to the file at the time it is opened. Consequently, it is possible to successfully open a file on a full disk. Under these circumstances, a 'Disk full' error would be reported when you tried to write data to the file for the first time.
The example below writes the contents of two arrays (tables) to a file called 'TOPTEN.BBC'.
10 A=OPENOUT "TOPTEN" 20 FOR Z=1 TO 10 30 PRINT#A,N(Z),N$(Z) 40 NEXT 50 CLOSE#A 60 END