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 />

FIELD Statement<br />

Purpose:<br />

To allocate space for variables in a random file buffer.<br />

Syntax:<br />

FIELD [#] filenum, width AS stringvar [,width AS stringvar]...<br />

Comments:<br />

filenum is the number under which the file was opened.<br />

width is the number of characters to be allocated to the string variable.<br />

string variable is a string variable which will be used for random file access.<br />

A FIELD statement must have been executed before you can<br />

● Get data out of a random buffer after a GET statement<br />

● Enter data before a PUT statement<br />

For example, the following line allocates the first 20 positions (bytes) in the random file buffer to<br />

the string variable N$, the next 10 positions to ID$, and the next 40 positions to ADD$:<br />

FIELD 1, 20 AS N$, 10 AS ID$, 40 AS ADD$<br />

FIELD only allocates space; it does not place any data in the random file buffer.<br />

The total number of bytes allocated in a FIELD statement must not exceed the record length<br />

specified when the file was opened. Otherwise, a "Field overflow" error occurs (the default<br />

record length is 128).<br />

Any number of FIELD statements may be executed for the same file, and all FIELD statements<br />

executed are in effect at the same time.<br />

Note<br />

Do not use a fielded variable name in an INPUT or LET statement. Once a variable name is<br />

fielded, it points to the correct place in the random file buffer. If a subsequent INPUT or LET<br />

statement with that variable name is executed, the variable's pointer is moved to string space (see<br />

LSET/RSET and GET statements).<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/FIELD.html28/03/2004 21.29.26

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

Saved successfully!

Ooh no, something went wrong!