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

The GW-BASIC statements DEFINT, DEFSTR, DEFSNG, and DEFDBL may be included in a<br />

program to declare the types of values for certain variable names.<br />

6.2.3 Array Variables<br />

An array is a group or table of values referenced by the same variable name. Each element in an<br />

array is referenced by an array variable that is a subscripted integer or an integer expression. The<br />

subscript is enclosed within parentheses. An array variable name has as many subscripts as there<br />

are dimensions in the array.<br />

For example,<br />

V(10)<br />

references a value in a one-dimensional array, while<br />

T(1,4)<br />

references a value in a two-dimensional array.<br />

The maximum number of dimensions for an array in GW-BASIC is 255. The maximum number<br />

of elements per dimension is 32767.<br />

Note<br />

If you are using an array with a subscript value greater than 10, you should use the DIM<br />

statement. Refer to the GW-BASIC <strong>User's</strong> Reference for more information. If a subscript greater<br />

than the maximum specified is used, you will receive the error message "Subscript out of<br />

range."<br />

Multidimensional arrays (more than one subscript separated by commas) are useful for storing<br />

tabular data. For example, A(1,4) could be used to represent a two-row, five-column array such<br />

as the following:<br />

Column 0 1 2 3 4<br />

Row 0 10 20 30 40 50<br />

Row 1 60 70 80 90 100<br />

In this example, element A(1,2)=80 and A(0,3)=40.<br />

Rows and columns begin with 0, not 1, unless otherwise declared. For more information, see the<br />

OPTION BASE statement in the GW-BASIC <strong>User's</strong> Reference.<br />

6.2.4 Memory Space Requirements for Variable Storage<br />

The different types of variables require different amounts of storage. Depending on the storage<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/Chapter 6.html (4 of 12)28/03/2004 21.29.00

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

Saved successfully!

Ooh no, something went wrong!