Constants - Campbell CR300 Series Product Manual

Compact datalogger
Hide thumbs Also See for CR300 Series:
Table of Contents

Advertisement

As Float
specifies the default data type. If no data type is explicitly specified with the
Float
statement, then
performed internally in IEEE 4 byte floating point with some operations calculated in double
precision. A good rule of thumb is that resolution will be better than 1 in the seventh digit.
As Long
specifies the variable as a 32 bit integer. There are two possible reasons a user would
do this: (1) speed, since the CR300 series Operating System can do math on integers faster than
with Floats, and (2) resolution, since the
Float. A good application of the
large.
As Boolean
specifies the variable as a 4 byte Boolean. Boolean variables are typically used for
flags and to represent conditions or hardware that have only 2 states (e.g., On/Off, High/Low). A
Boolean variable uses the same 32 bit long integer format as a
two values: True, which is represented as –1, and false, which is represented with 0. When a
Float
Long
integer is converted to a Boolean, zero is False (0), any non-zero value will set
or
the Boolean to True (-1). The Boolean data type allows application software to display it as an
On/Off, True/False, Red/Blue, etc.
The CR300 series uses –1 rather than some other non-zero number because the
operators are the same for logical statements and binary bitwise comparisons. The number -1 is
expressed in binary with all bits equal to 1, the number 0 has all bits equal to 0. When –1 is anded
with any other number the result is the other number, ensuring that if the other number is non-
zero (true), the result will be non-zero.
As String * size
with an optional size specifying the maximum number of characters in the string. A string is
convenient in handling serial sensors, dial strings, text messages, etc. When size is not specified, a
default of 24 characters will be used (23 usable bytes and 1 terminating byte).
As a special case, a string can be declared
single character. The string will take up 4 bytes in memory and when stored in a data table, but it
will hold only one character.

16.4.2 Constants

Const
The
declaration is used to assign a name that can be used in place of a value in the data
logger CRBasic program. Once a value is assigned to a constant, each time the value is needed in
the program, the programmer can type in the constant name instead of the value itself. The use
Const
of the
declaration can make the program easier to follow, easier to modify, and more
secure against unintended changes. Unlike variables, constants cannot be changed while the
program is running.
is assumed. Measurement variables are stored and calculations are
Long
As Long
specifies the variable as a string of ASCII characters, NULL terminated,
As String
has 31 bits compared to the 24 bits in the
declaration is a counter that is expected to get very
Long
* 1. This allows the efficient storage of a
As
but can set to only one of
AND
and
16. Working with data     80
OR

Advertisement

Table of Contents
loading

Table of Contents