Campbell Scientific CR9000X Measurement and Control System User Manual
Page 172

Section 5. Program Declarations
AS
The declaration of variables (via the DIM or the PUBLIC statement) allow an
optional type descriptor AS that specifies the data type. The default data type,
without a descriptor, is IEEE4 floating point (FLOAT). The data types are
FLOAT, LONG, BOOLEAN, and STRING.
AS FLOAT specifies the default IEEE4 data type. If no data type is explicitly
specified with the AS statement, then FLOAT is assumed.
Public Z, RefTemp, TCTemp(3)
Public X AS FLOAT
AS LONG specifies the variable as a 32 bit long integer, ranging in values
from –2,147,483,648 to +2,147,483,647 (31 bits plus the sign bit). There are
two possible reasons a user would do this:
1, Speed, since the OS can do math on integers faster that with floats.
2. Resolution, LONG has 31 bits compared to the 24 bits in the IEEE4.
Dim I AS LONG
Public LongCounter AS LONG
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, Ports). A Boolean variable uses the same 32 bit
long integer format as a LONG but can set to only one of two values: True,
which is represented as –1, and false, which is represented with 0. The
Boolean data type allows application software to display it as an ON/OFF,
TRUE/FALSE , RED/BLUE, etc.
Public Switches(8) AS BOOLEAN, FLAGS(16) AS BOOLEAN
AS STRING * size specifies the variable as a string of ASCII characters,
NULL terminated, with size specifying the maximum number of characters in
the string. A string is convenient for handling serial sensors, dial strings, text
messages, etc.
String arrays can only have up to 2 dimensions instead of the 3 allowed for
other data types. (This is because the least significant dimension is actually
used as the size of the string.)
Public FirstName AS STRING * 20
Public LastName AS STRING * 20
5-2