EasyManuals Logo

Campbell CR1000 User Manual

Campbell CR1000
678 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #136 background imageLoading...
Page #136 background image
Section 7. Installation
(x) on the variable name. X number of variables are created that differ in name
only by the incrementing number in the suffix. For example, the four statements
Public TempC1
Public TempC2
Public TempC3
Public TempC4
can simply be condensed to
Public TempC(4).
This statement 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. 136)
shows compact code that converts four temperatures (°C) to °F.
In this example, a For/Next structure with an incrementing 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, as is the case in the declaration
Dim TempC()
CRBasic references only the first element of the array, TempC(1).
See CRBasic example Concatenation of Numbers and Strings
(p. 284) for an
example of using the += assignment operator
(p. 565) when working with arrays.
CRBasic Example 6. Using a Variable Array in Calculations
'This program example demonstrates the use of a variable array to reduce code. In this
'example, two variable arrays are used to convert four temperature measurements from
'degree C to degrees F.
Public TempC(4)
Public TempF(4)
Dim T
BeginProg
Scan(1,Sec,0,0)
Therm107(TempC(),1,1,Vx1,0,250,1.0,0)
Therm107(TempC(),1,2,Vx1,0,250,1.0,0)
Therm107(TempC(),1,3,Vx1,0,250,1.0,0)
Therm107(TempC(),1,4,Vx1,0,250,1.0,0)
For T = 1 To 4
TempF(T) = TempC(T) * 1.8 + 32
Next T
NextScan
EndProg
7.8.4.5 Declaring Local and Global Variables
Advanced programs may use subroutines (p. 288) or functions (p. 602), each of which
can have a set of Dim variables dedicated to that subroutine or function. These
136

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Campbell CR1000 and is the answer not in the manual?

Campbell CR1000 Specifications

General IconGeneral
Power Requirements9.6 to 16 VDC
Data Logger Operating SystemCRBasic
Memory4 MB
Analog Inputs16 single-ended or 8 differential
Analog Input Resolution13 bits
Analog Input Range+/-2.5V
Digital I/O8
Pulse Counters2
Communication PortsRS-232
Operating Temperature-25°C to +50°C
Pulse Channels4

Related product manuals