Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.


8.3 Named Constants

It is often nice to be able to give names to certain constants. For instance, as we saw earlier, the truth value TRUE actually represents the value -1, and FALSE represents zero (see 3.2.2 Logic and comparison). These are our first examples of named constants. To define your own you use the CONST keyword as follows:

CONST ONE=1, LINEFEED=10, BIG_NUM=999999

This has defined the constant ONE to represent one, LINEFEED ten and BIG_NUM 999,999. Named constants must begin with two uppercase letters, as mentioned before (see 6.1 Identifiers).

You can use previously defined constants to give the value of a new constant, but in this case the definitions must occur on different CONST lines.

CONST ZERO=0
CONST ONE=ZERO+1
CONST TWO=ONE+1

The expression used to define the value of a constant can use only simple operators (no function calls) and constants.


Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.