2 subroutines, 8 program execution timing, Crbasic example 10. use of a subroutine – Campbell Scientific CR200/CR200X-series Dataloggers User Manual
Page 95

Section 9. Programming
If Flag = True Then
DisableVar = True
End If
Else
DisableVar = False
EndIf
'Call Data Tables and Store Data
CallTable (OscAvgData)
NextScan
EndProg
Read More! For a complete list of output processing instructions, see
Data
Storage Output Processing
(p. 94).
9.7.2 Subroutines
Subroutines allow a section of code to be called by multiple processes in the
main body of a program. Subroutines are defined before the main program body
of a program. Program
CRBASIC EXAMPLE. Use of a Subroutine
p. 83 shows
the use of a subroutine to repeatedly perform a calculation.
CRBASIC EXAMPLE 10.
Use of a Subroutine
'Declare Variables and Units
Public Temp(4), I, Temp_F(4)
'Subroutine to convert temperature in degrees C to degrees F
Sub ConvertCtoF
For I = 1 to 4
Temp_F = Temp(I)*1.8 + 32
Next I
EndSub
'Main Program
BeginProg
Scan (1,Sec)
Therm109 (Temp(),4,1,Ex1,1.0,0)
'convert Temperatures to F using Subroutine:
Call ConvertCtoF
NextScan
EndProg
9.8 Program Execution Timing
CR200(X) programs are built within a Scan () / NextScan structure, with only
variable and data table declarations outside the Scan () / NextScan structure. In
these programs, Scan () / NextScan creates an infinite loop, each periodic pass
through the loop being synchronized to the CR200(X) clock. Scan () parameters
allow modification of the period. As shown in
CRBASIC EXAMPLE. BeginProg
/ Scan / NextScan / EndProg Syntax
(p. 84) , aside from declarations, the
CRBASIC program may be relatively short.
83