CON

Designator: Declare a Constant Block.

CON 
  Symbol = Expression
  Symbol = Expression
  ...
CON 
  Symbol = Expression, Symbol = Expression...
CON 
  #Expression, Symbol [Offset], Symbol [Offset]...
CON 
  #Expression, Symbol,
     Symbol [Offset]...
CON
  Symbol [Offset], Symbol [Offset]
    Symbol [Offset]...
  • Symbol is the desired name for the constant.
  • Expression is any valid integer, or floating-point, constant algebraic expression. Expression can include other constant symbols as long as they were defined previously.
  • Offset is an optional expression by which to adjust the enumeration value for the Symbol following this one. If Offset is not specified, the default offset of 1 is applied. Use Offset to influence the next Symbol's enumerated value to something other than this Symbol's value plus 1.

Explanation

The Constant Block is a section of source code that declares global constant symbols and global Propeller configuration settings. This is one of six special declarations (CON, VAR, OBJ, PUB, PRI, and DAT) that provide inherent structure to the Spin language.

Constants are numerical values that cannot change during run time. They can be defined in terms of single values (1, $F, 65000, %1010, %%2310, "A", etc.) or as expressions, called constant expressions, (25 + 16 / 2, 1000 * 5, etc.) that always resolve to a specific number.

The Constant Block is an area of code specifically used for assigning symbols (useful names) to constants so that the symbols can be used anywhere in code where that constant value is needed. This makes code more readable and easier to maintain should you later have to change the value of a constant that appears in many places. These constants are global to the object so that any method within it can use them. There are many ways to define constants.

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.