Oh, that's what you were shooting for. Okay, maybe you were just over-thinking it?
I get the two Steve's now. It needs to pick out the second one to be _INSTRREV() compliant. Good thinking!
Pete
Code: (Select All)
a$ = "much Steve go or after full Steve then if"
PRINT a$: PRINT
DO
LOCATE 10, 1: PRINT SPACE$(_WIDTH);
LOCATE 10, 1: LINE INPUT "Search term: "; b$
j = instrrev&(seed&, a$, b$)
PRINT: PRINT "INSTRREV ="; _INSTRREV(seed&, a$, b$), "Function ="; j
LOCATE 2: PRINT SPACE$(_WIDTH);
IF j THEN LOCATE 2, j: PRINT "^"
LOOP
FUNCTION instrrev& (seed&, strng$, srch$)
b$ = SPACE$(LEN(srch$))
FOR i& = LEN(b$) TO 1 STEP -1
j& = j& + 1
MID$(b$, j&, 1) = MID$(srch$, i&, 1)
NEXT
j& = 0
a$ = SPACE$(LEN(strng$))
FOR i& = LEN(a$) TO 1 STEP -1
j& = j& + 1
MID$(a$, j&, 1) = MID$(strng$, i&, 1)
NEXT
IF INSTR(seed&, a$, b$) THEN
instrrev& = LEN(a$) - LEN(b$) - (INSTR(seed&, a$, b$) - 2)
ELSE
instrrev& = 0
END IF
END FUNCTION
I get the two Steve's now. It needs to pick out the second one to be _INSTRREV() compliant. Good thinking!
Pete