17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

GW-BASIC <strong>User's</strong> Guide<br />

OPEN Statement<br />

Purpose:<br />

To establish input/output (I/O) to a file or device.<br />

Syntax:<br />

OPEN mode,[#]file number,filename[,reclen]<br />

OPEN filename [FOR mode][ACCESS access][lock] AS [#]file number<br />

[LEN=reclen]<br />

Comments:<br />

filename is the name of the file.<br />

mode (first syntax) is a string expression with one of the following characters:<br />

Expression Specifies<br />

O Sequential output mode<br />

I Sequential input mode<br />

R Random input/output mode<br />

A Position to end of file<br />

mode (second syntax) determines the initial positioning within the file, and the action to be taken<br />

if the file does not exist. If the FOR mode clause is omitted, the initial position is at the beginning<br />

of the file. If the file is not found, one is created. This is the random I/O mode. That is, records<br />

may be read or written at any position within the file. The valid modes and actions taken are as<br />

follows:<br />

INPUT Position to the beginning of the file. A "File not found" error is given if the<br />

file does not exist.<br />

OUTPUT Position to the beginning of the file. If the file does not exist, one is created.<br />

APPEND Position to the end of the file. If the file does not exist, one is created.<br />

RANDOM Specifies random input or output mode.<br />

mode must be a string constant. Do not enclose mode in double quotation marks. access can be<br />

one of the following:<br />

READ<br />

WRITE<br />

READ WRITE<br />

file number is a number between 1 and the maximum number of files allowed. The number<br />

associates an I/O buffer with a disk file or device. This association exists until a CLOSE or CLOSE<br />

file number statement is executed.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/OPEN.html (1 of 5)28/03/2004 21.29.39

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!