Skip to content
  • Home
  • Account
  • Restricted content
  • OBEX
  • Chips Tips
  • Logout
  • Shop
  • Blog
Propeller OBEX
  • OBEX
  • Forum
Login
Propeller OBEX
View Categories
  • Home
  • Docs
  • Spin Language Reference
  • Block Designators
  • CON

CON

Reading Time: 1 min read

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.

Was this useful ?
Share This Article :
  • Facebook
  • X
  • LinkedIn
Still stuck? How can we help?

Still stuck? How can we help?

Updated on February 20, 2025
Table of Contents
  • Explanation

Copyright © 2025 - Parallax Inc.
599 Menlo Drive | Rocklin, CA 95765 | USA