Constants are numbers which cannot be changed after they are defined. For example, 5 will always mean the same number.
    In ARMbasic, variable names can be told to be constants by defining them with the CONST command.

    Such constants are then available globally, meaning that once defined, you can use the word to refer to a constant anywhere in your program.

    After being defined with the CONST command, constants cannot be altered. If code tries to alter a constant, an error message will result upon code compilation.

    Only the first 32 characters of a constant name are used, beyond that they are truncated.

    By default, constants are defined by decimal numbers. Versions of the compiler after 7.43 also support VB style hex constants defined by &H, such as &H1000 = 4096.

    PBASIC style hex and binary constants may also be used.    A PBASIC style hex constant will begin with $, such as $3FAB.     PBASIC style Binary constants begin with %, such as %010101111.   While decimal constants can be signed, hex and binary constants are always unsigned.

    IEEE 754 floating point support has been added.  Constants for single numbers can be defined as an option - sign followed by decimal digits for the integer portion, followed by . then the fractional portion.  Such as 1234.568  55.  0.0000000003456


CONST PI = 3.14159265

CONST FirstNumber = 1
CONST SecondNumber = - 2

PRINT FirstNumber, SecondNumber 'This will print 1      -2

See also