Specifications
Section 11. Programming Resource Library
11-33
EXAMPLE 11.7-1. Use of Conditional Compile Instructions #If, #ElseIf, #Else and #EndIf
'Conditional Compilation Example for CR3000 / CR1000 / CR800 Series Dataloggers
'Here we choose to set program options based on the
'setting of a constant in the program.
Const ProgramSpeed = 2
#If ProgramSpeed = 1
Const ScanRate = 1 '1 Second
Const Speed = "1 Second"
#ElseIf ProgramSpeed = 2
Const ScanRate = 10 '10 Seconds
Const Speed = "10 Second"
#ElseIf ProgramSpeed = 3
Const ScanRate = 30 '30 Seconds
Const Speed = "30 Second"
#Else
Const ScanRate = 5 '5 Seconds
Const Speed = "5 Second"
#EndIf
'Here we choose a COM port depending on which
'logger type the program is running in.
#If LoggerType = CR3000
Const SourcSerialPort = Com3
#ElseIf LoggerTypes = CR1000
Const SourcSerialPort = Com2
#ElseIf LoggerType = CR800
Const SourcSerialPort = Com1
#Else
Const SourcSerialPort = Com1
#EndIf
'Public Variables.
Public ValueRead, SelectedSpeed As String * 50
'Main Program
BeginProg
'Return the selected speed and logger type for display.
#If LoggerType = CR3000
SelectedSpeed = "CR3000 running at " & Speed & " intervals."
#ElseIf LoggerTypes = CR1000
SelectedSpeed = "CR1000 running at " & Speed & " intervals."
#ElseIf LoggerType = CR800
SelectedSpeed = "CR800 running at " & Speed & " intervals."
#Else
SelectedSpeed = "Unknown Logger " & Speed & " intervals."
#EndIf
'Open the serial port.
SerialOpen (SourcSerialPort,9600,10,0,10000)