MPE/iX - CI Programming for Stability
July 18, 2008 HP World '01 87
Assume variable X = "ab c;de,,fg;hij=k lmn,op=qr” and 500 iterations for timing tests
• Test for word “hi” somewhere in a string var
• pos(“hi”, x) is wrong, e.g. “high”, “highest” will also match
• word(x, , , , pos(“hi”, x)) = “hi” works correctly
• Count tokens in a string var
• setvar cnt wordcnt(x)
• Remove Nth token from a string var
• setvar y lft(x, delimpos(x, , N-1)) + rht(x, -delimpos(x, , N) -1)
# note: removes the right hand delimiter from X after extraction # 526 msecs
OR
• setvar y xword(x, , N) # note: same as above # 364 msecs
• Remove N consecutive tokens from a string var
• # assume we are removing tokens 5,6,7 so N=3 and START=5:
setvar y lft(x, delimpos(x, , START-1)) + rht(x, -delimpos(x, , START+N-1) -1)
String manipulations (cont)