RosettaCodeData/Task/Search-a-list/Yabasic/search-a-list.basic

21 lines
446 B
Plaintext

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