HP 3000 Manuals

Ap B. Expression Evaluator Functions [ MPE/iX Commands Reference Manual Volume I ] MPE/iX 5.0 Documentation


MPE/iX Commands Reference Manual Volume I

Appendix B  Expression Evaluator Functions 

The expression evaluator is a system procedure used by the user interface
to accept a string, number, or Boolean expression, evaluate it, and
return the result.  This procedure is used by the CALC, SETVAR, IF,
ELSEIF, and WHILE commands in the MPE/iX command interpreter (CI). 

The expression evaluator provides the following:

   *   Consistent evaluation of expressions.

   *   Compatibility with MPE V/E job control word evaluation.

   *   User flexibility.

The expression evaluator uses algebraic notation and supports the
functions defined in table B-1.  The references that appear in this table
in parentheses, for example (8), are defined following the table.

          Table B-1.  Expression Evaluator Functions 

-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
|          Symbol          |      Function      |            Example             |       Result       |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| +(numeric)               | addition           | 4 + 5                          | 9                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| +(string)                | concatenate        | "abc" + "de"                   | abcde              |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| -(numeric)               | subtraction        | 12 - 6                         | 6                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| -(string)                | deletion of first  | "abc" - "b"                    | ac                 |
|                          | occurrence         |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| *                        | multiplication     | 4 * 5                          | 20                 |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| /                        | integer division   | 79/ 10                         | 7                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| ^                        | exponentiation (9) | 2^3                            | 8                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| either " or '            | string identifier  | either "abc" or 'abc'          | abc                |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| ()                       | parentheses        | (3 + 4) * 2                    | 14                 |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| <                        | less than (1)      | 5 < 6                          | TRUE               |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| <=                       | less than or equal | "abc" <= "abc"                 | TRUE               |
|                          | (1)                |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| >                        | greater than (1)   | "xyz" > "abc"                  | TRUE               |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| >=                       | greater than or    | "abc" >= "abc"                 | TRUE               |
|                          | equal (1)          |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| <>                       | not equal          | 5 <> 6                         | TRUE               |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| =                        | equal              | "xyz"= "xyz"                   | TRUE               |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| ABS(integer)             | absolute value     | abs(-4)                        | 4                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| ALPHA(string)            | check if a string  | alpha('abcd')                  | TRUE               |
|                          | is alphabetic      | alpha('ab3d ef')               | FALSE              |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| ALPHANUM(string)         | check if a string  | alphanum('abCd')               | TRUE               |
|                          | is only            | alphanum('45abd') alphanum('3d | TRUE               |
|                          | alphabetics and    | ef')                           | FALSE              |
|                          | digits             |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| AND                      | logical and        | 7=7 and 5=5                    | TRUE               |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| BAND                     | bitwise and        | 7 band 13                      | 5                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| BNOT                     | bitwise not        | bnot 5                         | -6                 |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------

          Table B-1.  Expression Evaluator Functions (Cont.) 

-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
|          Symbol          |      Function      |            Example             |       Result       |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| BOR                      | bitwise or         | 5 bor 2                        | 7                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| BOUND(varname)           | variable           | bound(HPPATH)                  | TRUE               |
|                          | definition test    |                                |                    |
|                          | (2)                |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| BXOR                     | bitwise exclusive  | 7 bxor 5                       | 2                  |
|                          | or                 |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| CHR(integer)             | ASCII value        | chr(65)                        | A                  |
|                          | (integer) ===>     |                                |                    |
|                          | character          |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| CSL                      | circular shift     | -2 csl 2                       | -5                 |
|                          | left (3)           |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| CSR                      | circular shift     | -7 csr 1                       | -4                 |
|                          | right (3)          |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| DWNS(string)             | shift string to    | dwns('aBC&#dE')                | abc&#de            |
|                          | lowercase (7)      |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| FINFO(filename,option)   | file information   | FINFO('x.pub',0)               | TRUE               |
|                          | (6)                |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| HEX(integer)             | convert to         | hex(329)                       | $149               |
|                          | hexadecimal string |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| INPUT([prompt][,wait])   | accept user input  | input('Enter choice:',20)      | Enter choice:  Y   |
|                          | (10)               |                                | Return "Y"         |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| LEN(string)              | string length      | len("abc")                     | 3                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| LFT(string, # chars)     | left string        | lft('abc',2)                   | ab                 |
|                          | extraction         |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| LSL                      | logical shift left | 7 lsl 1                        | 14                 |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| LSR                      | logical shift      | -7 lsr 1                       | 2,147,483,644      |
|                          | right              |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| LTRIM(string[,trimstr])  | trim left end of   | 'X'+ltrim(' abc')              | Xabc               |
|                          | string (11)        | "X"+ltrim('...abc', '.')       | Xabc               |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| MAX(num1[,num2...])      | find largest of    | max(5,4-3,70,0)                | 70                 |
|                          | several integers   |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| MIN(num1[,num2...])      | find smallest of   | min(5,4,-3,70,0)               | -3                 |
|                          | several integers   |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| MOD                      | modulo (4)         | 25 mod 2                       | 1                  |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| NOT                      | logical not        | not(2>1)                       | FALSE              |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| NUMERIC (string)         | check if a string  | numeric('12345')               | TRUE               |
|                          | is all digits      | numeric('$a234ef')             | FALSE              |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------

          Table B-1.  Expression Evaluator Functions (Cont.) 

-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
|          Symbol          |      Function      |            Example             |       Result       |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| OCTAL(integer)           | convert to octal   | octal(329)                     | %511               |
|                          | string             |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| ODD(integer)             | determine if       | odd(233)                       | TRUE               |
|                          | integer is odd     | odd(-2)                        | FALSE              |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| OR                       | logical or         | 5=5 or 2=3                     | TRUE               |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| ORD(string)              | ordinal (8)        | ord('AbcD')                    | 65                 |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| POS(find str,source      | find Nth           | pos('ab','cgabd')              | 3                  |
| str[,n])                 | occurrence of find | pos('.','file.grp.acct',2)     | 9                  |
|                          | str in source str  | pos('.','file.grp.acct',-1)    | 9                  |
|                          | (-N searches from  |                                |                    |
|                          | right) (12)        |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| RHT(string, # chars)     | right string       | rht("abc",2)                   | bc                 |
|                          | extraction         |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| RPT(string,count)        | repeat a string    | rpt('aBc',3)                   | aBcaBcaBc          |
|                          | (-count reverses   | rpt('aBc',-3)                  | cBacBacBa          |
|                          | string)            |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| RTRIM(string[,trimstr])  | trim right end of  | rtrim('abc ')+'X'              | abcX               |
|                          | string (11)        | rtrim('abc...','.')+"X"        | abc X              |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| SETVAR(varname,expr)     | return result of   | setvar(myvar,2*3+5)            | sets variable      |
|                          | expr and set       |                                | myvar to 11 and    |
|                          | varname to result  |                                | returns 11         |
|                          | (13)               |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| STR(string,start pos, #  | general string     | str('abcde',2,3)               | bcd                |
| chars)                   | extraction         |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| TYPEOF(expression)       | type of variable   | typeof(HPPATH)                 | 2 (string)         |
|                          | or expression (5)  |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| UPS(string)              | shift string to    | ups('aBc5d')                   | ABC5D              |
|                          | uppercase (7)      |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------
|                          |                    |                                |                    |
| XOR                      | logical exclusive  | 7=7 xor 5=5                    | TRUE               |
|                          | or                 |                                |                    |
|                          |                    |                                |                    |
-------------------------------------------------------------------------------------------------------



MPE/iX 5.0 Documentation