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

DIM Statement<br />

Purpose:<br />

To specify the maximum values for array variable subscripts and allocate storage accordingly.<br />

Syntax:<br />

DIM variable(subscripts)[,variable(subscripts)]...<br />

Comments:<br />

If an array variable name is used without a DIM statement, the maximum value of its subscript(s)<br />

is assumed to be 10. If a subscript greater than the maximum specified is used, a "Subscript<br />

out of range" error occurs.<br />

The maximum number of dimensions for an array is 255.<br />

The minimum value for a subscript is always 0, unless otherwise specified with the OPTION<br />

BASE statement.<br />

An array, once dimensioned, cannot be re-dimensioned within the program without first<br />

executing a CLEAR or ERASE statement.<br />

The DIM statement sets all the elements of the specified arrays to an initial value of zero.<br />

Examples:<br />

10 DIM A(20)<br />

20 FOR I=0 TO 20<br />

30 READ A(I)<br />

40 NEXT I<br />

This example reads 21 DATA statements elsewhere in the program and assigns their values to A<br />

(0) through A(20), sequentially and inclusively. If the A array is single precision (default<br />

accuracy) then line 10 will allocate 84 bytes of memory to this array (4 bytes times 21 elements).<br />

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

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

Saved successfully!

Ooh no, something went wrong!