Task[edit]
Find the index of a string (needle) in an indexable, ordered collection of strings (haystack).

Raise an exception if the needle is missing.

If there is more than one occurrence then return the smallest index to the needle.

Extra credit
Return the largest index to a needle that has multiple occurrences in the haystack.

See also
 Search a list of records

list$ = "mouse,hat,cup,deodorant,television,soap,methamphetamine,severed cat heads,cup"
 
dim item$(1)
 
n = token(list$, item$(), ",")
 
line input "Enter string to search: " line$
for i = 1 to n
    if line$ = item$(i) then
        if not t print "First index for ", line$, ": ", i
        t = i
        j = j + 1
    end if
next
 
if t = 0 then
    print "String not found in list"
else
    if j > 1 print "Last index for ", line$, ": ", t
end if