Campbell Scientific CR1000KD CR1000 Measurement and Control System - Page 116
Function
View all Campbell Scientific CR1000KD manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 116 highlights
Section 7. Installation 116 variables can be viewed through the external keyboard / display or software numeric monitors. Dim variables cannot. All user defined variables are initialized once when the program starts. Additionally, variables that are used in the Function() or Sub() declaration,or that are declared within the body of the function or subroutine are local to that function or subroutine. Variable names can be up to 39 characters in length, but most variables should be no more than 35 characters long. This allows for four additional characters that are added as a suffix to the variable name when it is output to a data table. Variable names can contain the following characters: • A to Z • a to z • 0 to 9 • _ (underscore) • $ Names must start with a letter, underscore, or dollar sign. Spaces and quote marks are not allowed. Variable names are not case sensitive. Several variables can be declared on a single line, separated by commas: Public RefTemp, AirTemp2, Batt_Volt Variables can also be assigned initial values in the declaration. Following is an example of declaring a variable and assigning it an initial valued. Public SetTemp = {35} In string variables, string size defaults to 24 characters (changed from 16 characters in April 2013, OS 26). Arrays When a variable is declared, several variables of the same root name can also be declared. This is done by placing a suffix of "(x)" on the alphanumeric name, which creates an array of x number of variables that differ only by the incrementing number in the suffix. For example, rather than declaring four similar variables as follows, Public TempC1 Public TempC2 Public TempC3 Public TempC4 simply declare a variable array as shown below: Public TempC(4), This creates in memory the four variables TempC(1), TempC(2), TempC(3), and TempC(4). A variable array is useful in program operations that affect many variables in the same way. CRBasic example Using a variable array in calculations (p. 117) shows program code using a variable array to reduce the amount of code required to convert four temperatures from Celsius degrees to Fahrenheit degrees.