/* REXX CKAL demonstrates 'finding which word contains a string'. It does this via a practical example of finding all aliases and their basenames as reported via MEMBERS. Written by Frank Clarke long ago Modification History 20021003 fxc neatening; */ arg argline address TSO arg parms "((" opts opts = Strip(opts,"T",")") parse var opts "TRACE" tv . parse value tv "N" with tv . rc = Trace("O"); rc = Trace(tv) "NEWSTACK" "MEMBERS @@.REXX ((ALIAS STACK" pull mbrlist "DELSTACK" lastpt = "" /* MEMBERS responds to 'ALIAS' by listing any aliases immediately following their base member. Each alias is suffixed with '(*)' to identify it as an alias. This loop finds the last occurrence of '(*)' and determines which word contains this glyph. It then walks backward through the string until it finds a word which does NOT end with '(*)', the base member. Then it finds the next-last alias, etc. */ pt = Lastpos( "(*)" , mbrlist ) /* last alias */ do forever if pt = 0 then leave wordct = Words(Left(mbrlist,pt) ) /* which word is it in? */ parse value Word(MBRLIST,wordct) with aliasname "(" do zx = wordct to 1 by -1, until(Right(Word(mbrlist,zx),3) <> "(*)") end push Right(aliasname,9) "is an alias of" Word(mbrlist,zx) lastpt = pt pt = Lastpos( "(*)" , mbrlist,lastpt) /* last alias */ end /* forever */ do queued() parse pull line; say line end exit /*@ CKAL */