82
6.3.3 Logical Operators
A logical operator combines multiple tests and manipulates Boolean operands, then returns
the results. It is used, for example, to control the program execution flow or test the value of an
INP
function bitwise, as shown in the sample below.
IF d<200 AND f<4 THEN ...
WHILE i>10 OR k<0 ...
IF NOT p THEN ...
barcod% = INP(0) AND &h02
Listed below are the four types of logical operators available.
One or more spaces or tab codes should precede and follow the
NOT
,
AND
,
OR
, and
XOR
operators.
In the logical expressions (or operands), the logical operator first carries out the type conver-
sion to integers before performing the logical operation. If the resultant integer value is out of
the range from -32768 to +32767, a run-time error will occur.
If an expression contains logical operators together with arithmetic and relational operators,
the logical operators are given lowest precedence.
[ 1 ] The
NOT
operator
The
NOT
operator reverses data bits by evaluating each bit in an expression and setting the
resultant bits according to the truth table below.
Syntax:
NOT expression
Truth Table for
NOT
For example,
NOT
0
= -1 (true).
The
NOT
operation for an integer has the returned value of negative 1’s complement. The
NOT
X, for instant, is equal to –(X+1).
Operations
Logical Operators
Precedence
Negation
NOT
1
Logical multiplication
AND
2
Logical addition
OR
3
Exclusive logical addition
XOR
4
Bit in Expression
Resultant Bit
0
1
1
0
Summary of Contents for BHT-BASIC 100 SERIES
Page 1: ......
Page 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Page 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Page 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Page 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...