EasyManua.ls Logo

Campbell CR300 series - Declaring Data Types; B-2. Data Types in Variable Memory; Crbasic Examples

Campbell CR300 series
86 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Appendix B. Introduction to CRBasic Programming
B-4
B.2.1 Declaring Data Types
Variables and data values stored in final memory can be configured with
various data types to optimize program execution and memory usage.
The declaration of variables with the Public or Dim instruction allows an
optional type descriptor As that specifies the data type. The default data type
(declaration without a descriptor) is IEEE4 floating point, which is equivalent
to the As Float declaration. Variable data types are listed in TABLE B-2.
CRBasic Example B-3 shows various data types in use in the declarations and
output sections of a program.
TABLE B-2. Data Types in Variable Memory
Name Command Description
Word Size
(Bytes)
Notes Resolution / Range
Float
As Float or
As IEEE4
IEEE floating point 4
Data type of all variables unless
declared otherwise.
IEEE Standard 754
±1.4E45 to ±3.4E38
Double
As Double or
As IEEE8
Double precision
floating point
8
IEEE Standard 754
Use to minimize floating point errors
when doing floating point
calculations or to store measurements
of high-resolution digital sensors.
Suitable for storing numbers larger
than Longs.
±4.94065E-324 to ±1.79769E308
Long
As Long
Signed integer 4
Use to store integer data.
Speed: integer math is faster than
floating point math.
Resolution: 32 bits.
Suitable for storing whole numbers,
counting numbers, and integers in
final-data memory. If storing non-
integers, the fractional portion of the
value is lost.
2,147,483,648 to +2,147,483,647
Boolean
As Boolean
Signed integer 4
Use to store true or false states, such
as states of flags and control ports. 0
is always false. 1 is always true.
Depending on the application, any
other number may be interpreted as
true or false. See Appendix B.9,
Expressions
(p. B-13).
True = 1 or any number ≥ 1
False = any number ≥ 0 and < 1
String
As String
ASCII string
Minimum: 3
(4 with null
terminator)
Default: 24
Maximum:
limited only
to the size of
available
CR300
memory.
See caution.
1
String size is defined by the CR300
operating system and the CRBasic
program.
When converting from String to
Float, numerics at the beginning of a
string convert, but conversion stops
when a non-numeric is encountered.
If the string begins with a non-
numeric, the Float will be NAN. If
the string contains multiple numeric
values, the SplitStr() instruction can
be used to parse out the numeric
values. Refer to CRBasic Editor
Help.
Unless declared otherwise, string size is 24
bytes or characters. String size is allocated
in multiples of four bytes; for example,
String * 25, String * 26, String * 27, and
String * 28 allocate 28 bytes (27 usable).
Minimum string size is 4 (3 usable). See
CRBasic Editor Help for more information.
Maximum length is limited only by
available CR300 memory.
1
CAUTION: When using a very long string in a variable declared
Public
, the operations of datalogger support software will frequently transmit the entire
string over the communication link. If communication bandwidth is limited, or if communications are paid for by the byte, declaring the variable Dim
may be preferred.

Table of Contents

Other manuals for Campbell CR300 series

Related product manuals