04.01.2015 Views

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Section 7. Installation<br />

In this example, a For/Next structure with a changing variable is used to specify<br />

which elements of the array will have the logical operation applied to them. The<br />

CRBasic For/Next function will only operate on array elements that are clearly<br />

specified and ignore the rest. If an array element is not specifically referenced,<br />

e.g., TempC(), CRBasic references only the first element of the array, TempC(1).<br />

CRBasic Example 7.<br />

Public TempC(4)<br />

Public TempF(4)<br />

Dim T<br />

Using a Variable Array in Calculations<br />

BeginProg<br />

Scan(1,Sec,0,0)<br />

Therm107(TempC(),4,1,Vx1,0,250,1.0,0)<br />

For T = 1 To 4<br />

TempF(T) = TempC(T) * 1.8 + 32<br />

Next T<br />

NextScan<br />

EndProg<br />

Dimensions<br />

Some applications require multi-dimension arrays. Array dimensions are<br />

analogous to spatial dimensions (distance, area, and volume). A single-dimension<br />

array, declared as VariableName(x), with (x) being the index, denotes x number<br />

of variables as a series. A two-dimensional array, declared as<br />

Public (or Dim) VariableName(x,y)<br />

with (x,y) being the indices, denotes (x * y) number of variables in a square x-byy<br />

matrix. Three-dimensional arrays (VariableName (x,y,z), (x,y,z) being the<br />

indices) have (x * y * z) number of variables in a cubic x-by-y-by-z matrix.<br />

Dimensions greater than three are not permitted by CRBasic.<br />

When using variables in place of integers as the dimension indices, e.g., CRBasic<br />

example Using variable array dimension indices (p. 117), declaring the indices As<br />

Long variables is recommended as doing so allows for more efficient use of<br />

<strong>CR1000</strong> resources.<br />

CRBasic Example 8.<br />

Using Variable Array Dimension Indices<br />

Dim aaa As Long<br />

Dim bbb As Long<br />

Dim ccc As Long<br />

Public VariableName(4,4,4) As Float<br />

117

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!