CR200/CR200X Series Dataloggers - Campbell Scientific
CR200/CR200X Series Dataloggers - Campbell Scientific
CR200/CR200X Series Dataloggers - Campbell Scientific
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Section 9. Programming<br />
Variable names can be up to 16 characters in length, but most variables should<br />
be no more than 12 characters long. This allows for the 4 additional characters<br />
that are added as a suffix to the variable name when it is output to a data table.<br />
Variable names cannot start with a number or contain spaces or quote marks (“),<br />
but can contain numbers and underscores (_). Several variables can be declared<br />
on a single line, separated by commas:<br />
Public RefTemp, AirTemp2, Batt_Volt<br />
9.6.1.1 Arrays<br />
When a variable is declared, several variables of the same root name can also be<br />
declared. This is done by placing a suffix of "(x)" on the alphanumeric name,<br />
which creates an array of x number of variables that differ only by the<br />
incrementing number in the suffix. For example, rather than declaring four<br />
similar variables as follows,<br />
Public TempC1<br />
Public TempC2<br />
Public TempC3<br />
Public TempC4<br />
simply declare a variable array as shown below:<br />
Public TempC(4),<br />
This creates in memory the four variables TempC(1), TempC(2), TempC(3),<br />
and TempC(4).<br />
A variable array is useful in program operations that affect many variables in the<br />
same way. CRBASIC EXAMPLE. Using a Variable Array in Calculations (p.<br />
74) shows program code using a variable array to reduce the amount of code<br />
required to convert four temperatures from Celsius degrees to Fahrenheit<br />
degrees.<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,<br />
TempC(1).<br />
74