17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

COM2: Input, Output, or Random Only<br />

Disk files allow all modes.<br />

When a disk file is opened for APPEND, the position is initially at the end of the file, and the<br />

record number is set to the last record of the file (LOF(x)/128). PRINT, WRITE, or PUT then<br />

extends the file. The program may position elsewhere in the file with a GET statement. If this is<br />

done, the mode is changed to random and the position moves to the record indicated.<br />

Once the position is moved from the end of the file, additional records may be appended to the<br />

file by executing a GET #x, LOF(x)/reclen statement. This positions the file pointer at the end<br />

of the file in preparation for appending.<br />

Any values entered outside of the ranges given result in "Illegal function call" errors.<br />

The files are not opened.<br />

If the file is opened as INPUT, attempts to write to the file result in "Bad file mode" errors.<br />

If the file is opened as OUTPUT, attempts to read the file result in "Bad file mode" errors.<br />

Opening a file for OUTPUT or APPEND fails, if the file is already open in any mode.<br />

Since it is possible to reference the same file in a subdirectory via different paths, it is nearly<br />

impossible for GW-BASIC to know that it is the same file simply by looking at the path. For this<br />

reason, GW-BASIC does not let you open the file for OUTPUT or APPEND if it is on the same<br />

disk, even if the path is different. For example if mary is your working directory, the following<br />

statements all refer to the same file:<br />

OPEN "REPORT"<br />

OPEN "\SALES\MARY\REPORT"<br />

OPEN "..\MARY\REPORT"<br />

OPEN "..\..\MARY\REPORT"<br />

At any one time, it is possible to have a particular diskette filename open under more than one<br />

file number. Each file number has a different buffer, so several records from the same file may be<br />

kept in memory for quick access. This allows different modes to be used for different purposes;<br />

or, for program clarity, different file numbers to be used for different modes of access.<br />

If the LEN=reclen option is used, reclen may not exceed the value set by the /s:reclen<br />

switch option in the command line.<br />

In a network environment, the use of the OPEN statement is based upon two different sets of<br />

circumstances:<br />

● Devices may be shared on a network for specific purposes only, so that OPEN statements<br />

may be restricted to specific modes among those which might be requested, such as:<br />

INPUT, OUTPUT, APPEND, and default (random).<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/OPEN.html (3 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!