Expressions In Arguments - Campbell CR300 Series Operator's Manual

Hide thumbs Also See for CR300 Series:
Table of Contents

Advertisement

Appendix B. Introduction to CRBasic Programming
NOTE
B.9.1 Expressions in Arguments
B-14
Logical expressions are used to indicate absence or presence of an event. For
example, a relative humidity measurement of 100% indicates a condensation
event such as fog, rain, or dew. The CR300 can render the state of the event
into binary form for further processing, so the event is either occurring (true),
or the event has not occurred (false).
In all cases, 0 is translated as False in logical expressions; by extension, any
non-zero number is considered "non-False." However, True is predefined in
the CR300 operating system to equal –1, so only –1 is always translated as
True. Consider the expression
If
Condition = TRUE Then...
This condition is true only when Condition = –1. If Condition is any other non-
zero, the condition will not be found true because the constant True is
predefined as –1 in the CR300 system memory. By entering = True, a literal
comparison is done. Consider the expression
If
Condition Then...
Since = True is omitted from the expression, Condition is considered true if it
equals any non-zero value.
True is –1 so that every bit is set high (–1 is &B11111111 for all
four bytes). This allows the AND operation to work correctly. The
AND operation does an AND Boolean function on every bit, so
True AND X will be non-zero if at least one of the bits in X is
non-zero (if X is not zero). When a variable of data type
BOOLEAN is assigned any non-zero number, the CR300
internally converts it to –1.
Many CRBasic instruction parameters allow the entry of arguments as
expressions. If an expression is a comparison using logical operators, it will
return –1 if true and 0 if false. The following code snippet shows the use of an
expression as an argument in the TrigVar parameter of the DataTable()
instruction:
'DataTable(Name, TrigVar, Size)
DataTable(Temp, TC > 100, 5000)
With the trigger of TC > 100, a thermocouple temperature greater than 100 sets
the trigger to True and data are stored.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cr300-rf407Cr300-rf412Cr300-rf422

Table of Contents