HP (Hewlett-Packard) HP 3000 Laptop User Manual


 
744 Appendix B
Expression Evaluator Functions
Expression Evaluator Features
ABX
SETVAR Z “foo‘
CALC “AB‘ + Z
ABfoo
CALC “AB‘ + “!Z‘
ABfoo
CALC “AB‘ + !Z
error variable foo not found
SETVAR A “X‘+“Y‘
CALC A +“B‘
XYB
CALC “!HPTIMEF‘
8:26 AM
CALC HPTIMEF
8:26 AM
CALC !HPTIMEF
error
The error in the last example occurs because the dereferenced value of HPTIMEF is not a
valid expression.
Dereferencing of either kind is performed before any evaluation is carried out. The
following examples illustrate the consequences:
SETVAR B 2
SETVAR A B
error
The first command causes no problem. A variable, B, is created and its value is set to 2.
Because 2 is not surrounded by quotes, it is taken as an integer.
String Substitution assumes that an exclamation point introduces a variable name.
However, there are occasions when the user wants String Substitution to ignore an
exclamation point. Doubling the exclamation point will cause String Substitution to reduce
the two exclamation points to one, and ignore them as dereferencing characters.
Dereferencing takes place first, and B yields !B For additional information on variables
and dereferencing, refer to the Using the 900 Series HP 3000 Fundamental Skills
(32650-60039). Because B is not surrounded by quotes, it is not taken as a string, integer,
or a Boolean. Therefore, SETVAR A B produces an error.
The problem is corrected by changing the second command:
SETVAR B 2
SETVAR A “B‘ ** second command changed **
Now the variable A is given the string representation of !B.
Consequently,
SHOWVAR B
B=2
SHOWVAR A
A=!B
But,
CALC A + 2
produces an error. A has been assigned a string value (the result of B, which is the string
!B‘).
However,