Programmer's Calculator V2.73 for the Palm OS
Using the special variables Op1, Op2, and Disp
When you enter a number into the calculator the value is represented by the variable Op2. If you then press a key that has a function behind it that is not defined with the Immediate Result checkbox (default), then the value is copied to the Op1 variable. Values entered thereafter are accumulated, again, in the Op2 variable. So, for example, if I enter the keystrokes: 2 5 + 2 equal The Op2 varaible will first be 2 and then it will become 25 and when the + key is pressed, the value 25 is copied to the Op1 variable and the Op2 variable is cleared. When the 2 key is pressed, the Op2 variable will have the value 2 and finally when the equal key is pressed, the function will execute and the result 27 will be stored in the Op2 variable which also has the synonym Disp. Op1 also has a synonym which is Prev.
Contrast the above binary (meaning two operand) functionallity to that of the Lsft function which is defined as a unary operation (meaning to have one operand). Since the Immediate result checkbox is checked in this function declaration, the operation is performed immediately when the key is pressed. So, the value of the display which is contained in the Disp variable and also its synonym, Op2 is shifted left 1 bit via the expression Disp<<1. If we had forgotten to check the immediate checkbox, then the expression would not be executed immediately, the display would not shift the bit, and the value of the current display would be moved to the Op1 variable.
The variables Op1, Op2, Prev, and Disp cannot be assigned to except via the internal mechanisms of the calc. For example, it is illegal to do Disp=0. This will result in a "Expected num or ID" error. The only way to get a value into the Disp variable is via the return result of executing a program. Likewise, Op1 can only be assigned via the mechanism of pressing an operation key which will cause Disp to be copied into Op1. You can, however, freely use the values of these variables in expressions, for example it is legal to perform a Disp*Disp.