Luna supports ordinary numeric constants, strings and Constants-Object. Ordinary constants are any numerical values or strings, that can be used in the source code. Constants can defined only once in a class and are visible in sub-routines.

A special case for constants is the Constants-Object (data structure). Expressions with constants will be calculated into binary code before the program is compiled. Thus the definition of a constant through a mathematical term assigns the result of the calculation to the constant. In mathematical functions within the source code, constants are reduced to their respective range of values. This means the constant ‘100’ will be treated like the data type byte, ‘-100’ like a integer and ’12.34’ like a single.


To make pure constant calculations for the preprocessor recognizable, enclose they in brackets if the expression also conatins variables or similar. If the preprocessor can differentiate them this avoids unnecessary binary code.

The following constants are preset with a fixed value in the compiler.

NameDescription Type
PIThe number of PI (3.1415926) Single
COMPILER_VERSION_STRINGFull string of the compiler version. string
COMPILER_MAJOR_NUMBERThe main version of the compiler. integer
COMPILER_MINOR_NUMBERThe release version of the compiler. integer
COMPILER_UPDATE_NUMBERThe release-update version of the compiler. integer
COMPILER_BUILD_NUMBERThe build number of the compiler. integer

Definition und usage of constants:

Const Number1 = 100
Const Number2 = 33.891
Const Number3 = (12 + 10) / 7      ' Number3 = 3.14285
Const String1 = "I’m a string"
dim x as single
x=Number1+Number2  ' Assignment of the value 133.891, corresponding to x = 133.891
print String1    ' Output: ‘I’m a string’