CONST
PET VIC-20 C64 C16 Plus/4 C128 X16 M65
The const directive defines a constant. Constants are named values that exist in compile-time only and are replaced with their numeric value in runtime.
Syntax
[SHARED] CONST <name> [AS <type>] = <value>
The <value> must be a numeric literal or an expression that only contains numeric literals or other constants.
Numeric literals and CONST values defined without an explicit type are untyped. An untyped constant adapts to the type of the other operand, e.g. b + 1 is a BYTE operation if b is a BYTE. If the constant does not fit in that type, the operation is promoted to the smallest type that can hold both, e.g. b + 300 is a WORD operation and b * -1 is an INT operation.
A constant declared with `AS <type>` is typed and behaves like a variable of that type in expressions.
Constants have the same visibility options as variables.
Examples
' -- Constants can be used to improve the readability of your code CONST BORDER = $d020 CONST BLACK = 0 POKE BORDER, BLACK