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

CHARACTER haystack='Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo.'
CHARACTER needle*10
 
DLG(TItle="Enter search string", Edit=needle)
 
n = EDIT(Text=haystack, Option=2, End, Count=needle) ! Option = word
 
IF( n == 0 ) THEN
  WRITE(Messagebox="!") needle, "not found"    ! bus not found
ELSE
  first = EDIT(Text=needle, LeXicon=haystack)
  WRITE(ClipBoard) "First ", needle, "found in position ", first
  ! First bush      found in position 5
 
  last = EDIT(Text=haystack, End, Left=needle, Count=" ") + 1
  WRITE(ClipBoard) "Last ", needle, "found in position ", last
  ! Last bush      found in position 8
ENDIF