Section 7. Installation
CRBasic Example 8.
Using the Const Declaration
'This program example demonstrates the use of the Const declaration.
'Declare variables
Public
PTempC
Public PTempF
'Declare constants
Const
CtoF_Mult = 1.8
Const
CtoF_Offset = 32
BeginProg
Scan
(1,Sec,0,0)
PanelTemp
(PTempC,250)
PTempF = PTempC * Cto CtoF_Offset
NextScan
EndProg
7.8.4.7.1 Predefined Constants
Many words are reserved for use by CRBasic. These words cannot be used as
variable or table names in a program. Predefined constants include instruction
names and valid alphanumeric names for instruction parameters. On account the
list of predefined constants is long and frequently increases as the operating
system is developed, the best course is to compile programs frequently during
CRBasic program development. The compiler will catch the use of any reserved
words. Following are listed predefined constants that are assigned a value:
•
LoggerType = 1000 (as in CR1000)
These may be useful in programming.
7.8.4.8 Declaring Aliases and Units
A variable can be assigned a second name, or alias, in the CRBasic program.
Aliasing is particularly useful when using arrays. Arrays are powerful tools for
complex programming, but they place near identical names on multiple variables.
Aliasing allows the power of the array to be used with the clarity of unique
names.
The declared variable name can be used interchangeably with the declared alias in
the body of the CRBasic program. However, when a value is stored to final-
memory, the value will have the alias name attached to it. So, if the CRBasic
program needs to access that value, the program must use the the alias-derived
name.
Variables in one, two, and three dimensional arrays can be assigned units. Units
are not used elsewhere in programming, but add meaning to resultant data table
headers. If different units are to be used with each element of an array, first
assign aliases to the array elements and then assign units to each alias. For
example:
Alias var_array(1) = solar_radiation
Alias var_array(2) = quanta
Units solar_radiation = Wm-2
Units variable2 = moles_m-2_s-1
138
Содержание CR1000
Страница 2: ......
Страница 4: ......
Страница 6: ......
Страница 32: ......
Страница 36: ......
Страница 38: ......
Страница 40: ......
Страница 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Страница 96: ......
Страница 98: ...98 ...
Страница 302: ......
Страница 350: ...Section 8 Operation Figure 91 Pulse Sensor Output Signal Types Figure 92 Switch Closure Pulse Sensor 350 ...
Страница 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Страница 454: ...Section 8 Operation 8 8 1 Data Display Figure 116 Displaying Data with the Keyboard Display 454 ...
Страница 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Страница 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Страница 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Страница 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Страница 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Страница 478: ......
Страница 506: ......
Страница 536: ......
Страница 636: ......
Страница 642: ......
Страница 644: ......
Страница 676: ......
Страница 677: ......