Propeller Manual

Table Of Contents
2: Spin Language Reference – CON
Here, RunTest and RunVerbose are 1 and 2, respectively, and RunBrief and RunFull are 5 and
6, respectively. While this feature may be handy, to maintain good programming practices it
should only be used in rare cases.
A more recommended way to achieve the previous example’s result is to include the optional
Offset field. The previous code could have been written as follows:
CON
'Declare modes of operation
#1, RunTest, RunVerbose[3], RunBrief, RunFull
Just as before, RunTest and RunVerbose are 1 and 2, respectively. The [3] immediately
following
RunVerbose causes the current enumeration value (2) to be incremented by 3 before
the next enumerated symbol. The effect of this is also like before,
RunBrief and RunFull are
5 and 6, respectively. The advantage of this technique, however, is that the enumerated
symbols are all set relative to each other. Changing the line’s starting value causes them all
to change relatively. For example, changing the
#1, to #4 causes RunTest and RunVerbose to
be 4 and 5, respectively, and
RunBrief and RunFull to be 8 and 9, respectively. In contrast, if
the original example’s
#1 were changed to #4, both RunVerbose and RunBrief would be set to
5, possibly causing the code that relies on those symbols to misbehave.
The Offset value may be any signed value, but only affects the value immediately following
it; the enumerated value is always incremented by 1 after a Symbol that doesn’t specify an
Offset. If overlapping values are desired, specifying an Offset of 0 or less can achieve that
effect.
Syntax 3 is a variation of the enumeration syntax. It doesn’t specify any starting value.
Anything defined this way will always start with the first symbol equal to either 0 (for new
CON blocks) or to the next enumerated value relative to the previous one (within the same CON
block).
Scope of Constants
Symbolic constants defined in Constant Blocks are global to the object in which they are
defined but not outside of that object. This means that constants can be accessed directly
from anywhere within the object but their name will not conflict with symbols defined in
other parent or child objects.
Symbolic constants can be indirectly accessed by parent objects, however, by using the
constant reference syntax.
Propeller Manual v1.1 · Page 89