Terms #
- Expression - Any combination of symbols that can represent a value.
Constants #
Constants are named values that cannot change. They work like integers, but if a value is used often enough, using constants makes your code easier to read and modify.
Constants are declared in CON blocks.
CON
DOZEN = 12
Variables #
Variables are named values that can change. All variables in Spin consist of integers of different sizes.
| name | type | unsigned range | signed range |
byte | 8-bit integer | 0 - 255 | -128 - 127 |
word | 16-bit integer | 0 - 65,535 | -32,768 - 32,767 |
long | 32-bit integer | 0 - 4,294,967,295 | -2,147,483,648 - 2,147,483,647 |
Variables are created in a VAR block. They are initialized to zero by the compiler.
VAR
byte foo
word bar
long baz
Flow Control #
Indentation #
If Statements #
Loops #
All loops in Spin use the REPEAT command.