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.
Содержание CR5000
Страница 39: ...Section 1 Installation and Maintenance 1 15 S A N Y O FIGURE 1 11 6 Removal of band clamp and battery ...
Страница 40: ...Section 1 Installation and Maintenance 1 16 This is a blank page ...
Страница 54: ...Section 2 Data Storage and Retrieval 2 14 This is a blank page ...
Страница 88: ...Section 4 CRBasic Native Language Programming 4 12 This is a blank page ...
Страница 94: ...Section 5 Program Declarations 5 6 This is a blank page ...
Страница 172: ...Section 7 Measurement Instructions 7 46 This is a blank page ...
Страница 206: ......
Страница 236: ...Index Index 4 This is a blank page ...
Страница 237: ...This is a blank page ...