Open

Open filename$ [For <mode>][Access <access>] As [#]filenumber%

Establishes input/output (I/O) to a file.  

<mode> - determines the initial positioning within the file, and the action to be taken if the file does not exist.  
  • Input - Position to the beginning of the file. A "File not found" error is given if the file does not exist.  
  • Output - Position to the beginning of the file. If the file does not exist, one is created.
  • Append - Position to the end of the file. If the file does not exist, one is created.
  • Random - Specifies random input or output mode. 
<access> can be one of the following : Read, Write, Read Write  

In place of <mode> you write one of the three modes - these are Output, Append, and Input. 
The Output mode permits you to write information to the file. 
If the file already exists, the old file will be overwritten with the new information, destroying all previous contents of the file. 

If the file does not already exist, a file with that name will be create. 
The Append mode allows you to write information to the file without destroying the old information - the new data just will be added onto the end of the file. 
Again, if the file does not already exist, it will be created. 
Finally, the Input mode permits you to read information from the file. 
If the file does not exist, the internal errno variable will be updated. 
You may read internal error number by using function Errno(). 
In place of filenumber% you write a number for the file (which must be an integer value >= 1). 
In subsequent nuBASIC statements you use this number when referring to the file. 
It is possible to have several files open at once, but each must have a different file number. 

See also Input#
Comments