Symbol
Syntax
Symbol Name { = } Value
Overview
Assign an alias to a register, variable, or constant value
Parameters
Name can be any valid identifier. Value can be any previously declared variable, system register, or a Register.Bit combination. The equals '=' symbol is optional, and may be omitted if desired.
When creating a program it can be beneficial to use identifiers for certain values that don't change: -
Symbol cMeter = 1
Symbol cCentimetre = 100
Symbol cMillimetre = 1000
This way you can keep your program very readable and if for some reason a constant changes later, you only have to make one change to the program to change all the values. Another good use of the constant is when you have values that are based on other values.
Symbol cMeter = 1
Symbol cCentimetre = (cMeter / 100)
Symbol cMillimetre = (cCentimetre / 10)
In the example above you can see how the cCentimetre and cMillimetre were derived from the cMeter constant.
Another use of the Symbol command is for assigning Port.Bit constants: -
Symbol LED_Pin = PORTA.0
PinHigh LED_Pin
In the above example, whenever the text LED_Pin is encountered, Bit-0 of PORTA is actually referenced.
FloatIng point constants may also be created using Symbol by simply adding a decimal point to a value.
Symbol cPI = 3.14 ' Create a floating point constant named cPI
Symbol cFlNum = 3.0 ' Create a floating point constant with the value 3
FloatIng point constant can also be created using expressions.
' Create a floating point constant holding the result of the expression
Symbol cQuanta = (3.3 / 1024)
Notes.
Symbol cannot create new variables, it simply aliases an identifier to a previously assigned variable, or assigns a constant to an identifier.
