Public – Campbell Scientific CR5000 Measurement and Control Module User Manual
Page 90

Section 5. Program Declarations
5-2
Const Declaration Example
The example uses Const to define the symbolic constant PI.
Const PI = 3.141592654
'Define constant.
Dim Area, Circum, Radius
'Declare variables.
Radius = Volt( 1 )
'Get measurement.
Circum = 2 * PI * Radius
'Calculate circumference.
Area = PI * ( Radius ^ 2 )
'Calculate area.
Dim
Declares variables and allocates storage space. In CRBasic, ALL variables MUST
be declared.
Syntax
Dim
varname[([subscripts]) [, varname[([subscripts])]]
Remarks
The Dim statement has these parts:
Part
Description
varname
Name of a variable.
subscripts
Dimensions of an array variable. You can declare multiple
dimensions.
The argument subscripts has the following syntax:
size [size, size]
In CRBasic the Option Base is always 1. This means the lowest number in a
dimension is 1 and not 0.
Dim A( 8, 3 )
The maximum number of array dimensions allowed in a Dim statement is 3. If a
program uses a subscript that is greater than the dimensioned value, a subscript out
of bounds error is recorded.
When variables are initialized, they are initialized to 0
Tip
Put Dim statements at the beginning of the program.
Public
Dimensions a variable as public and available in the Public table of the CR5000.
Syntax
Public(
list of [dimensioned] variables that make up the Public Table
)
Remarks
More than one Public statement can be made.