
Section 7. Installation
137
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. 138)
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. 492)
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 CR800 Series
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 34: ......
Page 54: ......
Page 92: ......
Page 310: ......
Page 446: ...Section 8 Operation 446 8 11 2 Data Display FIGURE 100 CR1000KD Displaying Data ...
Page 448: ...Section 8 Operation 448 FIGURE 102 CR1000KD Real Time Custom ...
Page 449: ...Section 8 Operation 449 8 11 2 3 Final Storage Data FIGURE 103 CR1000KD Final Storage Data ...
Page 450: ...Section 8 Operation 450 8 11 3 Run Stop Program FIGURE 104 CR1000KD Run Stop Program ...
Page 452: ...Section 8 Operation 452 FIGURE 106 CR1000KD File Edit ...
Page 456: ......
Page 462: ......
Page 523: ...Section 11 Glossary 523 FIGURE 116 Relationships of Accuracy Precision and Resolution ...
Page 524: ......
Page 526: ......
Page 556: ......
Page 558: ......
Page 560: ......
Page 597: ......