Constants

Constant is a code element, which value is set in the unit's descriptive part and remains constant during program execution.

All constants must be described in the separate section, which starts with the Const reserved work. The constant type is not specified. It will be defined automatically during the constant value analysis:

Const
    <identifier> = <constant value>;

Reserved Constants

Fore has reserved constants with fixed vales. In the code these constants are highlighted as keywords.

Name Constant description
True It returns logical True.
False It returns logical False.
Null It provides an empty reference that does not refer to any object. Setting it as a value causes resetting of the value and releasing resources spent to store value. Null as a value can be set for variables of one of the following types of data:
  • System or custom object.
  • Interface.
  • Variant.
  • Array.
On an attempt to specify Null as the variable value of a simple data type, the exception is thrown.

Example

Const
    _Name = "test.doc";
    _Path = "c:\Work\";
    _Max = 1000;
    _Min = 0;
    _Number = 86;

It is possible to determine a constant by expression calculation based on previously determined constants. The constants list given above can be continued:

Const
    //...
    Interval = _Max - _Min + 1;
    Center = (_Max - _Min) / 2;
    FullName = _Path + _Name;

All mathematical operators (+, -, /, *, div, mod), logical operators (not, or, and, xor), and relation operators may be used in expressions.

See also:

Fore Language Guide | Variables