; INSTR.ACT ; in-string? function for Action! ; By Bill Kendrick New Breed Software 1994 ; (Originally written for Glenn Saunders ) ; Accepts string to search in, string to look for, ; starting point in string to start searching; ; returns first location that string to look for is ; found in the string to search in, or 0 if it cannot ; be found. Byte Func InStr(Char Array String, Sub Byte Start) Byte Where,TempWhere,InSub,Look Where=0 ; init for this call TempWhere=0 InSub=1 If String(0)>=Start+Sub(0)-1 And String(0)>0 And Sub(0)>0 Then ; be sure enough room for it! For Look=Start To String(0) Do If String(Look)=Sub(InSub) Then If InSub=1 Then TempWhere=Look Fi ; this might be it InSub=InSub+1 If InSub>Sub(0) Then Where=TempWhere ; it IS it! Look=String(0) ; easy way to POP a FOR loop :) Fi Else If TempWhere<>0 Then Look=TempWhere Fi InSub=1 ; no, that's not it! TempWhere=0 Fi Od ; Look Fi Return(Where) PROC TEST() CHAR ARRAY A(100),B(100) BYTE W DO PRINTE("ENTER STRING") INPUTS(A) PRINTE("ENTER SEARCH") INPUTS(B) W=0 DO W=INSTR(A,B,W+1) PRINTBE(W) UNTIL W=0 OD ; SEARCH UNTIL NO MORE PUTE() UNTIL B(0)=0 OD RETURN