Campbell Scientific CR3000 Micrologger User Manual
Page 122

Section 7. Installation
122
In this example, a For/Next structure with a changing variable is used to specify
which elements of the array will have the logical operation applied to them. The
CRBasic For/Next function will only operate on array elements that are clearly
specified and ignore the rest. If an array element is not specifically referenced,
e.g., TempC(), CRBasic references only the first element of the array, TempC(1).
CRBasic Example 7.
Using a Variable Array in Calculations
Public
TempC(4)
Public
TempF(4)
Dim
T
BeginProg
Scan
(1,Sec,0,0)
Therm107
(TempC(),4,1,Vx1,0,250,1.0,0)
For
T = 1
To
4
TempF(T) = TempC(T) * 1.8 + 32
Next
T
NextScan
EndProg
Dimensions
Some applications require multi-dimension arrays. Array dimensions are
analogous to spatial dimensions (distance, area, and volume). A single-dimension
array, declared as VariableName(x), with (x) being the index, denotes x number
of variables as a series. A two-dimensional array, declared as
Public (or Dim) VariableName(x,y)
with (x,y) being the indices, denotes (x * y) number of variables in a square x-by-
y matrix. Three-dimensional arrays (VariableName (x,y,z), (x,y,z) being the
indices) have (x * y * z) number of variables in a cubic x-by-y-by-z matrix.
Dimensions greater than three are not permitted by CRBasic.
When using variables in place of integers as the dimension indices, e.g., CRBasic
example Using variable array dimension indices
(p. 122),
declaring the indices As
Long variables is recommended as doing so allows for more efficient use of
CR3000 resources.
CRBasic Example 8.
Using Variable Array Dimension Indices
Dim
aaa
As Long
Dim
bbb
As Long
Dim
ccc
As Long
Public
VariableName(4,4,4)
As Float