57 lines
2.1 KiB
Text
57 lines
2.1 KiB
Text
COMMENT
|
|
Variables are of six types, with arrays of each type being supported:
|
|
|
|
CHAR (or BYTE) FIXED
|
|
STRING REAL
|
|
INTEGER REAL.DOUBLE
|
|
|
|
Simple variables may be declared using the VAR, COMMON, and BASED keywords.
|
|
|
|
Arrays are declared using the DIM keyword and, if applicable, the COMMON or
|
|
BASE keyword. The maximum length of a string variable may be specified as
|
|
part of the declaration; if omitted, the default length is 80. Examples follow:
|
|
|
|
VAR FN = STRING:15
|
|
VAR X, Y, Z = INTEGER
|
|
VAR RATE = REAL
|
|
|
|
BASED IOBYTE = BYTE
|
|
COMMON ERROR_NUMBER = INTEGER
|
|
|
|
DIM REAL TEMPERATURES(20)
|
|
DIM INTEGER MATRIX(4,4)
|
|
DIM STRING:20 LASTNAMES(100)
|
|
DIM BASE BYTE FCB(16)
|
|
DIM COMMON INTEGER HISCORES(10)
|
|
|
|
Simple variables declared with VAR are placed in the data segment of the
|
|
compiled code. Variables declared COMMON are placed in a special data
|
|
segment that will be preserved during program chaining. Variables
|
|
declared using the BASED statement are positioned at run-time
|
|
using the BASE statement to specify the address, e.g.,
|
|
|
|
BASE IOBYTE AT 0003H
|
|
|
|
Arrays are dynamically created at run-time and do not occupy space in the
|
|
compiled code unless they are declared as COMMON. Arrays declared as BASE
|
|
are positioned at run-time using the LOCATE statement, e.g.,
|
|
|
|
LOCATE FCB AT 5CH
|
|
|
|
CHAR or BYTE variables occupy 1 byte. Character constants may be specified
|
|
using single quotes, e.g., 'A', or in decimal or hexadecimal form, e.g., 64
|
|
or 40H.
|
|
|
|
INTEGER variables occupy 2 bytes and may take signed decimal values from
|
|
-32768 to +32767 or unsigned hexadecimal values from 0000H to FFFFH.
|
|
|
|
FIXED variables occupy 6 bytes and can represent a sign and 11 digits in
|
|
packed BCD form, with 3 digits to the right of the decimal point. The
|
|
maximum value that can be represented is 99,999,999.995.
|
|
|
|
REAL variables occupy 4 bytes and can represent floating point values up
|
|
to 6 digits. Constants may be expressed as, e.g., 3.14159 or 3.14159E+1.
|
|
|
|
REAL.DOUBLE variables occupy 7 bytes and can represent floating point values
|
|
up to 12 digits.
|
|
END
|