About

The wasFindWord function finds a word within a sequence of token-delimited words and returns its index in the sequence.

For example:

Say wasFindWord('Search/For/Me', 'Me', '/')

will output: 3

Code

/*************************************************************************/
/*    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    */
/*************************************************************************/
wasFindWord: procedure /* Find the index of word in a string by token.  */
    Parse ARG String,Word,Token,Index
    If String = '' Then Return 0
    If Index = '' Then Index = 1
    Parse VAR String Head Interpret(Token) Tail
    If Head ~= Word Then Return wasFindWord(Tail,Word,Token,Index+1)
Return Index