Variables and Expressions

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

In MMBasic command names, function names, labels, variable names, file names, etc are not case sensitive, so that "Run" and "RUN" are equivalent and "dOO" and "Doo" refer to the same variable.

Variables
Variables can start with an alphabetic character or underscore and can contain any alphabetic or numeric character, the period (.) and the underscore (_). 
They may be up to 32 characters long.
A variable name or a label must not be the same as a function or one of the following keywords: THEN, ELSE, GOTO, GOSUB, TO, STEP, FOR, WHILE, UNTIL, LOAD, MOD, NOT, AND, OR, XOR, AS.
Eg, step = 5 is illegal as STEP is a keyword.

MMBasic supports three different types of variables:
1. Double Precision Floating Point.
These can store a number with a decimal point and fraction (eg, 45.386) however they will lose accuracy when more than 14 digits of precision are used. 
Floating point variables are specified by adding the suffix '!' to a variable's name (eg, i!, nbr!, etc). 
They are also the default when a variable is created without a suffix (eg, i, nbr, etc).
Maximite CMM MM150 MM170 use single precision floating point

2. 64-bit Signed Integer.
These can store positive or negative numbers with up to 19 decimal digits without losing accuracy but they cannot store fractions (ie, the part following the decimal point). 
These are specified by adding the suffix '%' to a variable's name. For example, i%, nbr%, etc.
Not applicable to Maximite CMM MM150 

3. A String.
A string will store a sequence of characters (eg, "Tom"). Each character in the string is stored as an eight bit number and can therefore have a decimal value of 0 to 255. 
String variable names are terminated with a '$' symbol (eg, name$, s$, etc). Strings can be up to 255 characters long.
Note that it is illegal to use the same variable name with different types. Eg, using nbr! and nbr% in the same program would cause an error. 
This is different from the original Colour Maximite which allowed this.


Most programs use floating point variables as these can deal with the numbers used in typical situations and are more intuitive when dealing with division and fractions. 
So, if you are not bothered with the details, always use floating point.


Constants
Numeric constants may begin with a numeric digit (0-9) for a decimal constant, &H for a hexadecimal constant, &O for an octal constant or &B for a binary constant. 
For example &B1000 is the same as the decimal constant 8. 
Constants that start with &H, &O or &B are always treated as 64-bit unsigned integer constants.
Decimal constants may be preceded with a minus (-) or plus (+) and may be terminated with 'E' followed by an exponent number to denote exponential notation. 
For example 1.6E+4 is the same as 16000.
When a constant number is used it will be assumed that it is an integer if a decimal point or exponent is not used. 
For example, 1234 will be interpreted as an integer while 1234.0 will be interpreted as a floating point number.
String constants are surrounded by double quote marks ("). Eg, "Hello World".

 

Last edited: 29 September, 2020