Remote Processing CAMBASIC User Manual

Page 36

Advertising
background image

Comm ands - 3

AND

Numeric Fun ction

SYNTAX:

n = a A N D b

PURPOSE:

P e r fo r m s b it w is e o r lo g ic a l o p er a ti on o n t w o n u mb e rs . A N D ' i ng is us ua ll y p e rf or m e d d u ri ng I/ O
operations to set a line low.

REMARK S:

Variables a and b are in the range of 0 to 65,535 (&FF FF). When printed, numbers greater than
32,768 are negative.

Logical A ND ' ing is perfo rme d during IF -TH EN o perations to test if all conditions ar e met.

RELATED:

OR, XOR

EXAMPLE:

10

A = INP(0)

:'get current status of port

20

A = A AND &FE

:'set bit number 1 low

30

OUT 0,A

:'output new status

40

PRINT A

RUN
8

Use AND in an IF-THEN statement to make sure all conditions are true.

10

IF (TEMPERATURE > 100) AND (HUMIDITY < 5) THEN GOTO ..dry

When the variable TEM PERA TURE is more than 3 and variable HUM IDITY < 25 then the
condition is true. In this case, AND returns a true (non-zero) condition.

ERROR:

none

Advertising