HP (Hewlett-Packard) HP 3000 Laptop User Manual


 
Appendix B 743
Expression Evaluator Functions
Expression Evaluator Features
If a string is expected and a valid quoted string is not found, variable management is
called to determine if the token is a variable. If it is not a variable, an error is returned. If
it is a variable containing a string value, its contents is used in the expression. If the
variable contains something other than a string, an error is returned.
Provided below is information on other facts you should be aware of concerning evaluator
functions.
Ord
If the length of string> 1, then the value returned from ORD(string) is the ordinal value of
the first character in the string.
Strings
A “string‘ of characters must be surrounded with quotation marks (“ or ‘) in order to be
treated as a string. For example, a + 'a' is treated as the contents of the string variable
a concatenated to the string 'a' .
Evaluating a string that contains a string operator returns an error unless the string itself
is surrounded by quotation marks (“ or ‘). You may include quotation marks within a string
in this fashion: “a‘b“ is evaluated as a‘b, but a‘b by itself produces an error.
You may also use quote folding, for example, two adjacent quotes of the same type that
began the string. They are folded to one and the string is not terminated, for example:
setvar a "a quote is here""!"
This would put the string a quote is here"! into the string variable A.
Variables
Variables that are dereferenced by an ! are dereferenced to complete resolution or to the
limits of dereferencing (default is 30 levels). Variables may be used in expressions without
the !, of course. This is called implicit dereferencing, and these variables are dereferenced
to only one level.
For example, if variable A has a value of B, it is implicitly and explicitly dereferenced as B.
If this variable has a value of !B, implicit dereferencing yields !B. If you want A to be fully
dereferenced, you must use !A (explicit dereferencing) in the expression you want
evaluated.
Variables and Strings
Explicitly dereferenced variables should be placed within quotation marks if you want the
variable's value treated as a string. Doing this also eliminates problems that might arise if
the variable contains delimiters or operators. Refer to the discussion on "Strings" above.
For example:
SETVAR X 3
CALC “AB‘ + “!X‘
AB3
CALC “AB‘ + X
error
CALC “AB“ + “X‘