[PUBLIC | PRIVATE] CONST name = expression
Description
CONST declares constants, which can be used in expressions, in place of literal values. The required component, name, must follow standard variable naming conventions. The required component, expression, is any literal, constant, or combination that includes all arithmetic or logical operators (except IS).
The optional PUBLIC and PRIVATE keywords are used at script level, to designate constants as visible or invisible to FUNCTION procedures and SUB procedures. By default, all constants are PUBLIC, and available throughout the script and in all procedures. All constants declared inside procedures are available only within the procedure.
Multiple constants may be declared on a single line, by separating each constant assignment with a comma. If a PUBLIC or PRIVATE keyword is used in this manner, it will be applied to all constants declared on that line.
Example
REM CONST Example
'CONST defines constants
CONST SHAPE = "Rectangle"
PRIVATE CONST AREA = 51
PUBLIC CONST LENGTH = 7, WIDTH = 11
PrintArea LENGTH, WIDTH
SUB PrintArea(l, w)
DIM Area
Area = l * w
PRINT SHAPE & " area: " & l & " * " & w &_
" = " & Area
END SUB
Output
Rectangle area: 7 * 11 = 77
Related Items
FUNCTION, PUBLIC, PRIVATE, SUB