User Tools

Site Tools


Constants and Variables


Constants are static values used during execution of the program. There are two types of constants: string and numeric.

A string constant is a sequence of 0 to 255 alphanumeric characters enclosed in double quotation marks. The following are sample string constants:

"Number of Employees"

Numeric constants can be positive or negative. When entering a numeric constant you should not type the commas. For instance, if the number 10,000 were to be entered as a constant, it would be typed as 10000. The following are sample numeric constants:


Floating-point constants can be represented in exponential form (similar to scientific notation). A floating-point constant consists of an optionally-signed integer or fixed-point number (the mantissa), followed by the letter E and an optionally-signed integer (the exponent). The allowable range for floating-point constants is 1.0x10-127 to 9.99×10126. For example:



Variables are used to hold either numeric or string values during the execution of the program. There are two types of variables: string and numeric. Variables names can be from 1 to 12 characters long and must start with a letter. Only the first two characters are significant. AA, AAAA and AABB are all considered to be the same variable. String variable names are have a $ appended to the variable name. For example:


Variable names must start with a letter and not contain any keywords. For example the variable name FULLNAME$ is not allowed as it contains the keyword NAME.

Numeric variables can hold values in the range 1.0x10-127 to 9.99×10126. String variables can hold a maximum of 20 characters. If more than 20 characters are assigned to a variable, all characters after the 20th are discarded.


Arrays are used to hold a number of numeric values. Arrays names follow the same rules as numeric variables. It is possible to have arrays with the same name as numeric variables. Individual values are set and retrieved by appending the index enclosed in brackets after the variable name. By default the array index must be a number between 0 and 10. If the index is not a whole number, the fractional part will be discarded. The upper limit can be changed using the DIM statement. For example:

A(2.5)=41   ' this is the same as A(2)=41
basic/variables.txt · Last modified: 2017/07/20 22:05 by ncc