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

If OpenConsole()  ; Open a simple console to interact with user
  NewList Straws.s()
  Define Straw$, target$="TBA"
  Define found
 
  Restore haystack ; Read in all the straws of the haystack.
  Repeat
    Read.s Straw$
    If Straw$<>""
      AddElement(Straws())
      Straws()=UCase(Straw$)
      Continue
    Else
      Break 
    EndIf
  ForEver
 
  While target$<>""
    Print(#CRLF$+"Enter word to search for (leave blank to quit) :"): target$=Input()
    ResetList(Straws()): found=#False
    While NextElement(Straws())
      If UCase(target$)=Straws()
        found=#True
        PrintN(target$+" found as index #"+Str(ListIndex(Straws())))
      EndIf  
    Wend
    If Not found
      PrintN("Not found.")
    EndIf
  Wend 
EndIf
 
DataSection
  haystack:
  Data.s "Zig","Zag","Zig","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo",""
EndDataSection