Section 7. Installation
147
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.6.3.8 Declaring Constants
Declare a constant name at the beginning of a program to use the alphanumeric
name in place of a numeric or string value. In the body of the program, use the
name rather than the value itself to make the program more secure against
unintended changes, and easier to read and modify. CRBasic example Using the
Const Declaration
(p. 148)
shows how to declare and use constants.
If declared using ConstTable / EndConstTable instructions, constants can be
changed on the CR1000KD Keyboard/Display while the program is running
(Configure, Settings | Constant Table). Changes can also be made with the C
command in a terminal emulator (see Troubleshooting – Using Terminal Mode
(p.
.
Constants, in memory, are four-byte signed integers or floating point numbers of
up to about 500 characters in length (length limited to the maximum command
line
(p. 532)
length).
CRBasic syntax does not have a provision for declaring a data type for a constant,
so the compiler infers data type based on the format of the constant value
expression, which is usually a single scalar. There are three possible outcomes:
•
string — the constant expression produces a string or the value is
enclosed in quotes
•
integer — the constant expression does not produce a floating point
value or the constant does not have a decimal point. Range =
–
2,147,483,648 to 2,147,483,647
•
floating point. Range ≈
–1E38 to 1E38
If the constant is not written as a decimal, the compiler treats the value as an
integer. Integer and floating point values are represented by 32 bits. A floating-
point value achieves its extended range by using a base-two exponential format.
The range of integers that a floating-point value can reliably store is limited by the
Summary of Contents for CR3000 Micrologger
Page 2: ......
Page 3: ......
Page 4: ......
Page 6: ......
Page 30: ......
Page 34: ......
Page 36: ......
Page 96: ......
Page 485: ...Section 8 Operation 485 8 11 2 Data Display FIGURE 110 Keyboard and Display Displaying Data ...
Page 487: ...Section 8 Operation 487 FIGURE 112 CR1000KD Real Time Custom ...
Page 491: ...Section 8 Operation 491 FIGURE 116 Keyboard and Display File Edit ...
Page 496: ......
Page 502: ......
Page 564: ...Section 11 Glossary 564 FIGURE 126 Relationships of Accuracy Precision and Resolution ...
Page 566: ......
Page 594: ......
Page 598: ......
Page 600: ......
Page 602: ......
Page 624: ......
Page 642: ......
Page 643: ......