Section 7. Installation
are called
local
variables. Names of local variable can be identical to names of
global variables
(p. 517)
and to names of local variables declared in other
subroutines and functions. This feature allows creation of a CRBasic library of
reusable subroutines and functions that will not cause variable name conflicts. If
a program with local
Dim
variables attempts to use them globally, the compile
error
undeclared variable
will occur.
To make a local variable displayable, in cases where making it public creates a
naming conflict, sample the local variable to a data table and display the data
element table in a
numeric monitor
(p. 521).
When exchanging the contents of a global and local variables, declare each
passing / receiving pair with identical data types and string lengths.
7.8.4.6 Initializing Variables
By default, variables are set equal to zero at the time the datalogger program
compiles. Variables can be initialized to non-zero values in the declaration.
Examples of syntax are shown in CRBasic example
Initializing Variables
(p. 137).
CRBasic Example 7.
Initializing Variables
'This program example demonstrates how variables can be declared as specific data types.
'Variables not declared as a specific data type default to data type Float. Also
'demonstrated is the loading of values into variables that are being declared.
Public
aaa
As Long
= 1
'Declaring a single variable As Long and loading the value of 1.
Public
bbb(2)
As String
*20 = {"String_1", "String_2"}
'Declaring an array As String and
'loading strings in each element.
Public
ccc
As Boolean
= True
'Declaring a variable As Boolean and loading the value of True.
'Initialize variable ddd elements 1,1 1,2 1,3 & 2,1.
'Elements (2,2) and (2,3) default to zero.
Dim
ddd(2,3)= {1.1, 1.2, 1.3, 2.1}
'Initialize variable eee
Dim
eee = 1.5
BeginProg
EndProg
7.8.4.7 Declaring Constants
CRBasic example
Using the Const Declaration
(p. 137)
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. If declared using
ConstTable
/
EndConstTable
, constants can be
changed while the program is running by using the CR1000KD Keyboard Display
menu (
Configure
,
Settings
|
Constant Table
) or the
C
command in a terminal
emulator (see
Troubleshooting – Terminal Emulator
(p. 501)
).
Note
Using all uppercase for constant names may make them easier to recognize.
137
Summary of Contents for CR1000
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 36: ......
Page 38: ......
Page 40: ......
Page 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Page 96: ......
Page 98: ...98 ...
Page 302: ......
Page 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Page 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Page 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Page 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Page 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Page 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Page 478: ......
Page 506: ......
Page 536: ......
Page 636: ......
Page 642: ......
Page 644: ......
Page 676: ......
Page 677: ......