Understanding constants
It is often necessary to have an immutable variable. In other words, it is often necessary to declare a variable, assign it a value, and ensure that the value never changes. Possible examples of required constants are as follows:
- Mathematical constants such as pi
- Motor speeds that never change
- Machine part sizes for calculation (things such as gear ratios)
This list is by no means comprehensive, nor will you always need to declare constants for the preceding bullet items. Whether or not you declare a constant is up to you and the application that you’re developing. In short, you will declare a constant when you want to add a level of protection so that a variable’s value never changes.
Declaring a constant is very simple. You can either use the Auto Declare tool and simply check the CONSTANT box, or you can declare one manually with the following syntax:
VAR CONSTANT const: INT :...