Re: strtok
- Posted by "Juergen Luethje" <j.lue at gmx.de> Jun 06, 2005
- 491 views
don cole wrote: > I swear a saw a function in STRTOK or somewhere that will do the following: > But now I can't find it. > > TEAMS={"Wake Forest","Wyoming","western > michiga","wiscon","wiscon","youngst","yale"} > > a=find("wiscon",TEAMS) > > returns {5,6} find() is a built-in Eu function that would return 4 rather than {5,6} in this case. find() can be used easily to write a function like this:
global function find_all (object x, sequence source) integer p sequence ret p = find(x, source) if p = 0 then return {} end if ret = {p} for i = p+1 to length(source) do if equal(source[i], x) then ret &= i end if end for return ret end function constant TEAMS = {"Wake Forest","Wyoming","western michiga","wiscon","wiscon","youngst","yale"} ? find_all("wiscon",TEAMS)
... prints {4,5}. Regards, Juergen