Download Basic Compiler User's Manual V.2.0 - Kalisch Computer

Transcript
3.2
Variables
Variables are symbols used to represent data items, such as numerical values or character
strings that are used in a BASIC program. The value of a variable may be assigned explicitly
and can be changed during the execution of a program. Before a variable is assigned a value,
its value is assumed to be undefined.
3.2.1
Variable Names and Declaration Characters
Following are the rules for variable names and declaration characters:
a.
A variable name must begin with a letter (A through Z).
b.
The remaining characters can be letters, numbers, and/ or underscores.
c.
The last character can be one of these type declaration characters:
i. % integer
:
2 bytes
-32,768 to +32,767
ii. & long
:
4 bytes
-2,147,483,648 to +2,147,483,647
iii.
iv.
v.
! real number
$ string
nothing (default)
:
4 bytes
:
2 bytes
-32,768 to +32,767
d.
The variable name cannot be a BASIC reserved word.
e.
Variable names are not case sensitive.
3.2.2
Array Variables
An array is a group or table of values referenced by the same variable name. Each element in
an array is referenced by an array variable that is subscripted with an integer or an integer
expression.
a.
An array variable name has as many dimensions as there are subscripts in the array.
For example,
i. A(12) would reference a value in a one-dimension array.
ii. T(2,5) would reference a value in a two-dimension array, and so on.
b.
Each element in an array is referenced by an array variable that is subscripted with
an integer or an integer expression. For example,
i. DIM IntegerA%(20)
Declare an integer array with 20 elements.
ii.
iii.
iv.
DIM SringB$(100)
DIM RealC!(10)
DIM Tb(5,5)
v.
ArrayD(i+1, j)
Declare a string array with 100 elements.
Declare a real number array with 10 elements.
Declare a two-dimension integer array with 5X5
elements.
The elements of an array are subscripted with an
integer expression.
c.
The first element of an array is subscripted with 1.
d.
In CipherLab BASIC, the maximum number of dimensions for an array is 2, and up to
32,767 elements per dimension is allowed while compiling.
13