Declaring Data Types; B-2. Data Types In Variable Memory; Crbasic Examples - Campbell CR300 Series Operator's Manual

Hide thumbs Also See for CR300 Series:
Table of Contents

Advertisement

Appendix B. Introduction to CRBasic Programming
B.2.1 Declaring Data Types
Name
Command
Description
As Float or
Float
IEEE floating point
As IEEE4
As Double or
Double precision
Double
As IEEE8
floating point
Long
Signed integer
As Long
Boolean
As Boolean
Signed integer
String
ASCII string
As String
CAUTION: When using a very long string in a variable declared Public, the operations of datalogger support software will frequently transmit the entire
1
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.
B-4
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
Word Size
(Bytes)
Data type of all variables unless
declared otherwise.
4
IEEE Standard 754
IEEE Standard 754
Use to minimize floating point errors
when doing floating point
calculations or to store measurements
8
of high-resolution digital sensors.
Suitable for storing numbers larger
than Longs.
Use to store integer data.
Speed: integer math is faster than
floating point math.
Resolution: 32 bits.
4
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.
Use to store true or false states, such
as states of flags and control ports. 0
is always false. –1 is always true.
4
Depending on the application, any
other number may be interpreted as
true or false. See Appendix B.9,
Expressions
See caution.
1
String size is defined by the CR300
operating system and the CRBasic
Minimum: 3
program.
(4 with null
When converting from String to
terminator)
Float, numerics at the beginning of a
Default: 24
string convert, but conversion stops
Maximum:
when a non-numeric is encountered.
limited only
If the string begins with a non-
to the size of
numeric, the Float will be NAN. If
available
the string contains multiple numeric
CR300
values, the SplitStr() instruction can
memory.
be used to parse out the numeric
values. Refer to CRBasic Editor
Help.
Notes
±1.4E–45 to ±3.4E38
±4.94065E-324 to ±1.79769E308
–2,147,483,648 to +2,147,483,647
True = –1 or any number ≥ 1
False = any number ≥ 0 and < 1
.
(p. B-13)
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.
Resolution / Range

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cr300-rf407Cr300-rf412Cr300-rf422

Table of Contents