Previous: karid2 Up: ../karrtn.html Next: karlc


KARIDX

       INTEGER FUNCTION KARIDX (TEXTA,LOCA,LENA,
      #                         TEXTB,LOCB,LENB)

          Given  two packed character strings  defined by the
 arguments TEXTA,LOCA,LENA  and TEXTB,LOCB,LENB,  search  the
 first string for the  first occurrence of the second string.
 If any  of  the  arguments LOCA,  LENA,  LOCB, or  LENB  are
 invalid, or if the second  string is not found in the first,
 return  0. Otherwise,  return  its  index, or  position,  in
 TEXTA(*),  counting  from  the  first  character  stored  in
 TEXTA(*).  The result returned is thus always 0, or not less
 than   LOCA.   For  example,  KARIDX(5HHELLO,LOC,5,2HLO,1,2)
 returns the  value 4 if LOC = 1,2,3,  or 4, since the second
 string begins at the fourth position in the first string. If
 LOC is  outside the range 1..4, then  0 is returned.

          KARIDX is essentially  equivalent to the PL/1 INDEX
 function.  It is worth  noting that at  least two computers,
 the  DEC VAX-11/780  and  the  UNIVAC 1160,  have  a  single
 hardware instruction  for performing  the function  of  this
 routine.