
125
Program Configuration
Section 7-4
7-4-5
Variables
Variables are names used to represent values that are used in a BASIC pro-
gram. The value of a variable may be assigned as the result of calculations or
explicitly by the programmer with an assignment statement. If no value is
assigned to a numeric variable, it is assumed to be zero. If no value is
assigned to a character variable, it is assumed to be the null string.
Variables are made up of the variable name and the type declarator.
Variable Name
A variable may be up to 255 alphanumeric characters long. All characters are
valid. No variable can start with “FN” or a BASIC command name.
If a parameter begins with a reserved word, a SYNTAX ERROR will occur.
TOTAL and ABSOL, for example, cannot be used because they include
reserved words TO and ABS.
Type Declarator
The variable TYPE can be declared. This is done using a type declarator that
is placed after the variable name. Even if two variables have the same name,
they will be treated differently if they are declared as different types of vari-
ables.
Note
There is a second way to declare variable types. The BASIC statements
DEFINT, DEFLNG, DEFSTR, DEFSNG, and DEFDBL may be used to declare
the types for certain variable names, starting with a certain letter. By default,
all variables are declared as single-precision.
7-4-6
Variable Arrays
An array is a group of values of the same TYPE (either numeric or alphabetic)
that is stored and referenced as a unit by the same variable name. Each ele-
ment in an array has a unique position and is referenced by the name of the
array subscripted with an integer or integer expression.
There can be many dimensions to an array. The most common types are
one-, two-, and three-dimensional arrays. The number of dimensions of an
Single-precision (!)
Variable
Character
Numeric
Real number
Double-precision (#)
Short integer (%)
Long integer (&)
Integer (%, &)
Variable
up to 255 characters
starting with an
alphabetic character
Variable name
+
Character variable:
$
Short integer:
%
Long integer:
&
Single-precision real: !
Double-precision real: #
Type declarator
%
Short Integer
Uses 2 bytes per variable.
Example: A%
&
Long integer
Uses 4 bytes per variable
Example: A&
!
Single-precision real
Uses 4 bytes per variable.
Example: A or A!
#
Double-precision real
Uses 8 bytes per variable.
Example: A#
$
Character
Uses up to 255 characters. Example: A$
Содержание C200H-ASC11
Страница 1: ...C200H ASC11 ASC21 ASC31 ASCII Units Operation Manual Revised June 2000...
Страница 2: ...iv...
Страница 4: ...vi...