CONST

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

Syntax:
CONST id = expression [, id = expression] ...

Description:
Create a constant identifier which cannot be changed once created.
'id' is the identifier which follows the same rules as for variables. 
The identifier can have a type suffix (!, %, or $) but it is not required.  
If it is specified it must match the type of 'expression'. It does not follow any OPTION DEFAULT mode setting.


'expression' is the value of the identifier and it can be a normal expression (including user defined functions) which will be evaluated when the constant is created.
A constant defined outside a sub or function is global and can be seen throughout the program. 
A constant defined inside a sub or function is local to that routine and will hide a global constant with the same name.

 OPTION DEFAULT FLOAT ' this is the default setting
 
' Constants normally take on the appropriate type for the value being assigned to them
' Trying to assign a conflicting value will cause an error:
 CONST a% = 2.0
 PRINT a%
 CONST b% = 2.4
 PRINT b%
 CONST d! = &hFFFF
 PRINT d!
 
' Assigning a float to a DIMed integer variable is OK and the float is converted to integer.
' The internal conversion from float to Integer is equivalent to CINT(float)
 DIM c%
 c% =  2.4 : PRINT c% , CINT(2.4),  INT(2.4)
 c% =  2.4 : PRINT c% , CINT(2.6),  INT(2.6)
 c% = -2.4 : PRINT c% , CINT(-2.4), INT(-2.4)
 c% = -2.6 : PRINT c% , CINT(-2.6), INT(-2.6)
' Assigning a strict integer to a float variable is OK
 DIM e!
 e! = &hFFFF : PRINT e!
 e! = &hFFFFFFFFFFFFFFFF : PRINT e!
 
' Using the '\' integer divide with floats causes the floats to be converetd
' to integer before the division
 PRINT 9.6\2.4

Last edited: 05 August, 2022