I made a semisimple program that produces a list of substring locations within a string.
DEF ISINSTR(string$,sub$)
DIM INLIST%[0]
VAR I%,J%
FOR I%=0 TO LEN(string$)-1
J% = INSTR(I%,string$,sub$)
IF I% == J% THEN PUSH INLIST%,I%
NEXT
RETURN INLIST%
END
To use, just copy the DEF block or make it a COMMON DEF etc. that way~
and say
arrayvarname=ISINSTR("string here","e")
How?
This basically iterates through and checks for all possible occurrences of a substring within a string. When it finds one, it checks if it was found where it was looking or if INSTR was searching ahead. If it is where it should be, it adds that location to the list (which will be 0 in length if no match is found.)
Or this one by SquareFingers that he says is better (looks like it XD):
DEF ISINSTR(string$,sub$)
DIM INLIST%[0]
VAR I%
I%=INSTR(string$,sub$)
WHILE (I%>=0)
PUSH INLIST%,I%
I%=INSTR(I%+1,string$,sub$)
WEND
RETURN INLIST%
END
Thank you for improving this!