COMPUTE
Syntax COMPUTE [name operator operand]
Explanation The COMPUTE command is intended for working with variables inside the RCX robot controller. COMPUTE performs an arithmetic or boolean operation on a Logo name and an operand and stores the result into the Logo name. It is equivalent to the Logo command MAKE :name :name operator operand.

The input to this command is a three-element list. The first element is the name of the variable which is to be altered. The second input is the operator. The third input depends on the operation. The following operators and operands are defined:

* multiply Variable or integer value
/ divide Variable or integer value
+ add Variable or integer value
- subtract Variable or integer value
AND bitwise AND Variable or integer value
OR bitwise OR Variable or integer value
ABS absolute value Variable or integer value
SGN extract the sign of the Variable or integer value. This sets the variable to 1 if the operand is less than zero, to 0 if the operand is zero, and to 1 if the operand is greater than zero
= assignment Any RCX variable, random number, or numeric constant.

RCX variables are signed integer variables with a value range from –32768 to 32767. Overflows are not handled, so if a multiplication overflows this range, the result may be unexpected. If this command is used with normal Logo variables, there is no range limitiation. The special values for assignments are not available, however. It is only possible to assign other variables or numbers.

Use the RCX.PANEL command to display the RCX panel which displays the contents of all variables, sensors, and timers.

Examples RCX.NAMES [A B C]
COMPUTE [A = ?10]:A
Result: 3
COMPUTE [A + 5]:A
Result: 8

TopIndex