Language Elements

BASIC-80

If a variable is referenced before it has been assigned a value, its value is zero. The NEW, RUN, CLEAR, LOAD, and MERGE instructions set all variables to zero.

Individual variables can be specified by individual type identifier suffixes, which override group type identifiers used to specify blocks of variables. Table 2-5 shows these suffixes.

Blocks of variables beginning with specific characters can be specified as integer, single-precision, or double-precision with the DEFINT, DEFSNG, and DEFDBL statements. The general form of these statements is: DEFxxx m[-n], where n is any letter A through Z, and m is any letter A through Z that precedes n in the alphabet, (Le., the block L-Q is legal, but Q-L is not). In this way, all variables beginning with a certain letter or letters may be defined as one type.

The variable default type is single precision, as if a DEFSNG A-Z had been executed at the start of a given program. If certain variables should be of another type, you should define them at the start of the program to prevent errors. In all cases, the type identifiers (% for integer,! for single-precision, and I for double-precision) override any variable block type assignment.

Note that A$, AOJo, A!, and AI are four different variables. If the default variable type for variables beginning with the letter A is single precision, then A and A! are the same variable.

To economize on memory space and execution time, you should use integer representation rather than single-precision representation, and single-precision rather than double-precision, when this is possible.

String Data

BASIC-80 accepts strings of characters as data. Like numeric values, strings can be either constants or variables.

String Constants

A string constant is a group of characters, enclosed in quotation marks. Quotation marks cannot be used within string constants. String constants can be up to 255 characters long. Some string constants are:

"This is a string constant."

"48, 23H, 373799"

String Variables

String variables are string values which can change during program execution. A string variable name is one or more characters, the first of which must be a letter, followed by $. If more than two characters are entered as a variable name, onlv the first two are read.

String variables can contain strings of from 0-255 characters. When you first invoke BASIC-80, however, there is only storage space for 100 characters. The CLEAR command must be used to increase the amount of available string space. Here are some examples of assignments to strip.g variables:

A$ = "Enter next data string"

B$ = "40 * 1. 7234E + 3"

NAMES$ = "Warren, Mark, Evan"

2-8

Page 18
Image 18
Intel 9800758-02 manual String Constants, String Variables, This is a string constant, $ = Enter next data string