FIND$(where$, find$, positions%[]) function

Previous topic - Next topic

Dark Schneider

It could be like:
found% = FIND$(where$, find$, positions%[])
then use found% if you only are interested about if is contained, and positions%[] are the indexes (first char position in where$ of any appearance of find$) in the string if you need them.

Currently we only have INSTR() that only searches for the 1st one.

Crivens

I would prefer an INSTR$ that can also do the following:-
1. Pull out the offset of the Nth found string. So the 2nd "B" in "ABAAABAA" would be the 6th char (ie. 5 in current INSTR$)
2. Also do this backwards. So 2nd "B" backwards in above example would be the 2nd char
3. Do the above 2 every X characters. So, for example, if you have a quick and dirty list of 3 character names for users of "BOBSAMJOE" then you have BOB, SAM, and JOE. Validating against this you could say find me if user "BSA" is valid in the list. A normal INSTR$ would say it is, but you would normally then have to use a MOD to decide if it really is (ie. BSA doesn't start in the exact location for 3 character names so is invalid).  Incorporate this into INSTR$ and would be handy for quick and easy checks.
4. If you use -1 as the Nth parameter (ie. search for the -1st) then return the number of times the string is found. So searching for the -1st "A" in the above example gives you 6

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Crivens

Quotechanging INSTR would potentially break a lot of old code!
Not if you make optional parameters.

QuoteGLB is a programming language, right? So what is keeping you from implementing it yourself?
Indeed. And I do. Although it's always nice to build this sort of functionality directly into the language.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.