Specifications

Section 9. CR1000 Programming
9-27
EXAMPLE 9.13-5. Logical Expression Examples
a. If X >= 5 then Y = 0
Sets the variable Y to 0 if the expression “X >= 5” is true, i.e. if X is
greater than or equal to 5. The CR1000 evaluates the expression (X >= 5)
and registers in system memory a -1 if the expression is true, or a 0 if the
expression is false.
b. If X >= 5 AND Z = 2 then Y = 0
Sets Y = 0 only if both X >= 5 and Z = 2 are true.
c. If X >= 5 OR Z = 2 then Y = 0
Sets Y = 0 if either X >= 5 or Z = 2 is true.
d. If 6 then Y = 0.
“If 6” is true since “6” (a non-zero number) is returned, so Y will be set to
0 every time the statement is executed. Likewise, consider the equally
impractical statement
e. If 0 then Y = 0.
“If 0” is false since “0” is returned, so Y will never be set to 0 by this
statement.
f. Z = (X > Y).
Z will equal -1 if X > Y, or Z will equal 0 if X <= Y.
9.13.5 String Expressions
CRBASIC allows the addition or concatenation of string variables to variables
of all types using & and + operators. To ensure consistent results, use “&”
when concatenating strings. Use “+” when concatenating strings to other
variable types. EXAMPLE 9.13-6 demonstrates CRBASIC code for
concat
enating strings and integers.
EXAMPLE 9.13-6. CRBASIC Code: String and Variable Concatenation
'Declare Variables
Dim Wrd(8) As String * 10
Public Phrase(2) As String * 80
Public PhraseNum(2) As Long
'Declare Data Table
DataTable (Test,1,-1)
DataInterval (0,15,Sec,10)
'Write phrases to data table "Test"
Sample (2,Phrase,String)