Section 9. Programming
76
CRBASIC EXAMPLE 5.
Flag Declaration and Use
Public batt_volt
Public Flag
BeginProg
Scan (1,Sec)
Flag = IIF (Flag=0,0,-1)
If Flag = true Then
Battery (batt_volt)
EndIf
NextScan
EndProg
9.6.2
Constants
CRBASIC EXAMPLE. Using the Const Declaration
(p. 76) shows use of the
constant declaration. A constant can be declared at the beginning of a program
to assign an alphanumeric name to be used in place of a value so the program
can refer to the name rather than the value itself. Using a constant in place of a
value can make the program easier to read and modify, and more secure against
unintended changes.
Note
Using all uppercase for constant names may make them easier to
recognize.
CRBASIC EXAMPLE 6.
Using the Const Declaration
Public PTempC, PTempF
Const CtoF_Mult = 1.8
Const CtoF_Offset = 32
BeginProg
Scan (1,Sec,0,0)
Therm109 (PTempC,1,1,Ex1,1.0,0)
PTempF = PTempC * Cto CtoF_Offset
NextScan
EndProg
9.6.2.1
Predefined Constants
Several words are reserved for use by CRBASIC. These words cannot be used
as variable or table names in a program. Predefined constants include some
instruction names, as well as valid alphanumeric names for instruction
parameters. In general, instruction names should not be used as variable,
constant, or table names in a datalogger program, even if they are not
specifically listed as a predefined constant. If a predefined constant, such as
"Sub" is used as a variable in a program, an error similar to the following may
be, but is not always, displayed at CRBASIC pre-compile.
Compile Failed!
line 8: Sub is already is use as a predefined CONST.
Summary of Contents for CR200
Page 32: ...Section 2 Quickstart Tutorial 22 ...
Page 45: ...Section 3 Overview 35 3 3 Specifications ...
Page 46: ...Section 3 Overview 36 ...
Page 58: ...Section 4 Sensor Support 48 ...
Page 62: ...Section 5 Measurement and Control Peripherals 52 ...
Page 78: ...Section 8 CR200 X Configuration 68 ...
Page 102: ...Section 9 Programming 92 ...
Page 138: ...Section 11 Programming Resource Library 128 ...
Page 156: ...Section 16 Support Software 146 ...
Page 160: ...Section 17 Care and Maintenance 150 ...
Page 167: ...Section 18 Troubleshooting 157 18 3 3 2 Charging Circuit Test Solar Panel ...
Page 168: ...Section 18 Troubleshooting 158 18 3 3 3 Charging Circuit Test Transformer ...
Page 169: ...Section 18 Troubleshooting 159 18 3 3 4 Adjusting Charging Circuit Voltage ...
Page 170: ...Section 18 Troubleshooting 160 ...
Page 184: ...Appendix A Glossary 14 ...
Page 190: ...Appendix B Status Table and Settings 20 ...
Page 192: ...Appendix C Serial Port Pin Outs 22 ...
Page 211: ......