/* rexx */ /*-------------------------------------------------------------------*/ /* */ /* REXX Exec : COUNTSTR */ /* */ /* Description : Counts the number of occurances of the string in */ /* another string. */ /* */ /* Usage : x = CountStr('Needle','Haystack') */ /* */ /* Created on : 25 Apr 2001 */ /* Created by : Kevin Ferguson */ /* : Userid MIT001 */ /* : Using ABBYDALE.ALLFREE.REXX(COUNTSTR) */ /* */ /* Called by : */ /* */ /* Calls : Nothing */ /* */ /* Panels Used : None */ /* */ /* Change Activity : */ /* */ /* ©Copyright of Abbydale Systems LLC. */ /* */ /*-------------------------------------------------------------------*/ signal on novalue /* un-initialized vars*/ signal on halt /* attention key */ CountStr: find = ARG(1) where = ARG(2) if find = "" then signal novalue if where = "" then signal novalue RETURN length(space(where,0)), -length(space(translate(where,' ',find),0)) /*-------------------------------------------------------------------*/ /* End of CountStr Procedure */ /*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/ /* Trap NOVALUE Condition */ /*-------------------------------------------------------------------*/ novalue: say "NOVALUE entered from line" sigl say condition("D") say "The instruction is suppressed" address "TSO" "delstack" exit(16) /*-------------------------------------------------------------------*/ /* Trap HALT Condition */ /*-------------------------------------------------------------------*/ halt: say "HALT acknowledged in line" sigl say "Cleanup processing in progress" address "TSO" "delstack" exit(16) /*-------------------------------------------------------------------*/ /* End of COUNTSTR */ /*-------------------------------------------------------------------*/