HPlogo MPE/iX Commands Reference Manual > Appendix B Expression Evaluator Functions

Appendix B Expression Evaluator Functions

MPE documents

Complete PDF
Table of Contents
Index

Table of Contents
References
Expression Evaluator Features
Ord
Strings
Variables
Variables and Strings
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 and within a ![ ]..

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 "Expression Evaluator Functions". The references that appear in this table in parentheses, for example (8), are defined following the table.

See HELP for description of new functions and examples.

E.g. HELP FSYNTAX

Table B-1 Expression Evaluator Functions

Symbol Function Example Result
+(numeric)addition4 + 59
+(string)concatenate"abc' + "de'abcde
-(numeric)subtraction12 - 66
-(string)deletion of first occurrence"abc' - "b'ac
*multiplication4 * 520
/integer division79/ 107
^exponentiation (9)2^38
either " or 'string identifiereither "abc' or "abc'abc
()parentheses(3 + 4) * 214
<less than (1)5 < 6TRUE
<=less than or equal (1)"abc' <= "abc'TRUE
>greater than (1)"xyz' > "abc'TRUE
>=greater than or equal (1)"abc'>= "abc'TRUE
<>not equal5 <> 6TRUE
=equal"xyz"= "xyz"TRUE
ABS(integer)absolute valueabs(-4)4
ALPHA(string)check if a string is alphabetic alpha('abcd')
alpha('ab3d ef')
TRUE
FALSE
ALPHANUM(string)check if a string is only alphabetics and digits alphanum('abCd') alphanum('45abd') alphanum('3def') TRUE
TRUE
FALSE
ANDlogical and7=7 and 5=5TRUE
ANYPARM
BANDbitwise and7 band 135
BASENAME (string)returns the filename component CALC basename ('a.b.c')
CALC basename ('/a/b/c')
CALC basename ('./a/b')
CALC basename ("./a.sl",".sl")
CALC basename ('/')
CALC basename ("*feq")
CALC basename ('$null')
CALC basename ('abc.g','c')
CALC basename (/usr/lib/liby.a','.a')
CALC basename ('/usr/lib/liby.a','liby.a'
A
c
b
a

/
*FEQ
$NULL

AB

liby

liby.a
BNOTbitwise notbnot 5-6
BORbitwise or5 bor 27
BOUND(varname)variable definition test (2) bound(HPPATH)TRUE
BXORbitwise exclusive or7 bxor 52
CHR(integer)ASCII value (integer) ===> character chr(65)A
CSLcircular shift left (3)-2 csl 2-5
CSRcircular shift right (3)-7 csr 1-4
DECIMAL(string)returns a string value of an integer CALC decimal (255)
CALC len(decimal($ff))
setvar i 0
while setvar(i,i+1) < 10 and finfo("FILE"+DECIMAL(I), 'exists') do
...
255
3, $3, %3
DELIMPOS(str [,delims] [,nth] [,start]) returns index in str of the nth delimiter beginning at start; default delims are a space, a comma, a semicolon, an equals sign, left and right parentheses, left and right brackets, single quote, double quote, and Tab; default nth is 1; default start is 1 DELIMPOS('file a=bb, old;rec=40,,f,ascii')5
DIRNAME(string)returns dirctory components of a filename
DWNS(string)shift string to lowercase (7) dwns('aBC&#dE')abc&#de
EDIT(string, editstr [,start]) performs full REDO-like editing of a string EDIT(`abcdefg','>dd')
EDIT('ab cd;g', 'dwd')
'abce'
'cd;g'
FINFO(filename, option)file information (6) FINFO('x.pub',0)TRUE
FQUALIFY(string)returns a fully qualified filename CALC fqualify('a')




CALC fqualify('a.b')
CALC fqualify('a.b.c')
CALC fqualify('./a')
CALC fqualify('./A')





CALC fqualify('/a/b/c')
CALC fqualify('*a')
CALC fqualify('$null')
CALC dirname (fqualify('./a'))
A.GROUP.ACCOUNT
# when the CWD is your logon group or /CWD/A #when the CWD is a directory
A.B.ACCOUNT
A.B.C
/ACCOUNT/GROUP/a
A.GROUP.ACCOUNT # when the CWD is your logon group or /CWD #when the CWD is a directory
/a/b/c
*A
*$NULL
/ACCOUNT GROUP # when the CWD is your logon group or CWD # when the CWD is a directory
FSYNTAX()(string)returns the syntax of the passed filename argument fsyntax('a.b.c')
fsyntax('/a/b/c')
fsyntax('./ab@/c')
fsyntax($null')
fsyntax('a.b.c.d')
MPE
POSIX
POSIX;WILD
MPE;$FILE
MPE ERROR=426
HEX(integer)convert to hexadecimal string hex(329)$149
INPUT([prompt] [,wait])accept user input (10) input('Enter choice:',20)Enter choice: YReturn "Y"
LEN(string)string lengthlen("abc')3
LFT(string, # chars)left string extraction lft('abc',2)ab
LSLlogical shift left7 lsl 114
LSRlogical shift right-7 lsr 12,147,483,644
LTRIM(string [,trimstr]) trim left end of string (11)'X'+ltrim(' abc')
"X"+ltrim('...abc', '.')
Xabc
Xabc
MAX(num1 [,num2...]) find largest of several integersmax(5,4-3,70,0)70
MIN(num1 [,num2...]) find smallest of several integersmin(5,4,-3,70,0)-3
MODmodulo (4)25 mod 21
NOTlogical notnot(2>1)FALSE
NUMERIC(string)check if a string is all digits numeric('12345')
numeric('$a234ef')
TRUE
FALSE
OCTAL(integer)convert to octal stringoctal(329) %511
ODD(integer)determine if integer is oddodd(233)
odd(-2)
TRUE
FALSE
ORlogical or5=5 or 2=3TRUE
ORD(string)ordinal (8)ord('AbcD')65
POS(find-str, source-str [,n]) find nth occurrence of find str in source str; positive value for n begins search at left; negative value for n begins search at right) (12) pos('ab','cgabd')
pos('.','file.grp.acct',2)
pos('.','file.grp.acct',-1)
3
9
9
PMATCH(pattern, str [,start]) searches for pattern in a given string (str) starting at start; pattern may contain wildcards; default start is 1 PMATCH('f@','fread')
PMATCH('abc','abcd')
TRUE
FALSE
REPL(str, oldstr, newstr [,cnt] [,start]) in a given string (str), replaces cnt occurrences of oldstr with newstr, beginning at start; if cnt is positive, replacement begins at the left end of str; if negative, replacement begins at the right end of str; default start is 1; default cnt is zero (meaning all occurences) REPL('aaabcaab','aa','X')
REPL('aaabcaab','ab','',-1)
'XabcXb'
'aaabca'
RHT(string, # chars)right string extractionrht("abc',2)bc
RPT(string, count) repeat a string (-count reverses string) rpt('aBc',3)
rpt('aBc',-3)
aBcaBcaBc
cBacBacBa
RTRIM(string [,trimstr]) trim right end of string (11) rtrim('abc ')+'X'
rtrim('abc...','.')+"X"
abcX
abcX
SETVAR(varname, expr) return result of expr and set varname to result (13) setvar(myvar,2*3+5) sets variable myvar to 11 and returns 11
STR(string, start-pos, # chars) general string extraction str('abcde',2,3)bcd
TYPEOF(expression)type of variable or expression (5) typeof(HPPATH)2 (string)
UPS(string)shift string to uppercase (7) ups('aBc5d') ABC5D
WORD(string [,delims] [,nth] [,end_var] [,start]) performs general word extraction; default delims are a space, a comma, a semicolon, an equals sign, left and right parentheses, left and right brackets, single quote, double quote, and Tab; default nth is 1; the default end_var is no variable; the default start is 1 WORD('file a=bb,old; rec=40,,f,ascii')
WORD('file a=bb,old; rec=40,,f,ascii',,-4,j)
'file'

'40', j=18
XORlogical exclusive or7=7 xor 5=5TRUE
XWORDstring)returns a string less 'word' xword('file a=bb, old; rec=40, ,f, ascii')
xword('file a=bb, old; rec=40, ,f, ascii' , ,2)
xword('file a=bb, old; rec=40, ,f, ascii' , " ; , " , , j, 8)
xword('file a=bb, old; rec=40, ,f, ascii' , , -4, j)
'a=bb,old;rec=40, , f, ascii'
'file bb, old; rec=40 , , f, ascii'
'file a=old; rec=40 , ,f , ascii' and J=10

'file a=bb, old;rec=, f, ascii ' and J=18




Appendix A Predefined Variables in MPE/iX


References