
Section 9. Programming
DisableVar = True
End If
Else
DisableVar = False
EndIf
'Call Data Tables and Store Data
CallTable (OscAvgData)
NextScan
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
BeginProg
Scan (1,Sec)
Therm109 (Temp(),4,1,Ex1,1.0,0)
'convert Temperatures to F using Subroutine:
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
Komentarze do niniejszej Instrukcji