How to: |
The POSIT function finds the starting position of a substring within a larger string. For example, the starting position of the substring DUCT in the string PRODUCTION is 4. If the substring is not in the parent string, the function returns the value 0.
To use this function, you must import the function library MNTUWS. For information on importing this library see Accessing and Calling a Function.
There is also a POSIT function available for the reporting language. For information on this function, see POSIT: Finding the Beginning of a Substring.
POSIT(parent, substring)
where:
Alphanumeric
Is the parent string.
Alphanumeric
Is the substring for which to find the position.
POSIT displays all movie titles containing the word ROOF and the starting position of the ROOF string:
MAINTAIN FILE movies
Module Import (mntuws);
Case Top
For all next Moviecode into stk1
Where Title Contains 'ROOF';
Compute i/i2=1;
type " Title Start Position of word ROOF"
repeat stk1.Foccount
Compute STK1(i).POS/I3 = POSIT(STK1(I).TITLE, 'ROOF');
Type " <STK1(i).Title <<STK1(I).pos"
Compute i=i+1;
endrepeat
EndCase
END
The following are sample values for MOVIECODE and values for the result of the POSIT function:
Title Start Position of word ROOF FIDDLER ON THE ROOF 16 CAT ON A HOT TIN ROOF 18
WebFOCUS |