Program Declarations

Variables must be declared before they can be used in the program. Variables declared as Public can be viewed in display software. Variables declared using Dim cannot be viewed. Variables assigned to a fixed value are used as constants.

For example, in a CRBasic program there may be multiple temperature (or other) sensors that are wired to sequential channels. Rather than insert multiple instructions and several variables, a variable array with one name and many elements may be used. A thermocouple temperature might be called TCTemp. With an array of 20 elements the names of the individual temperatures are TCTemp(1), TCTemp(2), TCTemp(3), ... TCTemp(20). The array notation allows compact code to perform operations on all the variables. For example, to convert ten temperatures in a variable array from C to F:

For I=1 to 10

TCTemp(I)=TCTemp(I)*1.8+32

Next I

Aliases can also be created that will allow an element of an array or another data result to be referred to by a different name. To continue the example above, TCTemp(3) could be renamed using the following syntax:

Alias TCTemp(3) = AirTemp

In the display software, the more descriptive alias, AirTemp, would be used for the cell name.