Finding if a word is in a list of other words
Posted: Tue Oct 13, 2009 5:14 pm
I have made a small test for placing into my stack. What I'm after is very straightforward, but I can't work it out (must be the weather):
I've fields "B" and "F" and a button. Field "B" is blank, field "F" has a list of words, one per line. When I type a word into field "B" and press the button, I want to find out if the word typed is included in the list.
Just so you don't think I haven't tried
here are my failed attempts:
I guess I'm going to kick myself when I read the answer...any help appreciated please!

I've fields "B" and "F" and a button. Field "B" is blank, field "F" has a list of words, one per line. When I type a word into field "B" and press the button, I want to find out if the word typed is included in the list.
Just so you don't think I haven't tried

Code: Select all
on mouseUp
put field "B" into tWord
put field "F" into tAllWords
if (tWord is among the words of field "F") is true then ---- or is among tAllWords
answer "Yes, it is!!"
else
answer "no, sorry..."
end if
end mouseUp
on mouseUp
put field "B" into tWord
put field "F" into tAllWords
if tWord is in tAllWords then
answer "Yes, it is!!"
else
answer "no, sorry..."
end if
end mouseUp
on mouseUp
put field "B" into tWord
put field "F" into tAllWords
matchText tAllWords(quote &tWord"e)
if it is true then
answer "Yup"
else
answer "Nope!"
end if
end mouseUp
on mouseUp
put field "B" into tWord
put field "F" into tAllWords
if (tAllWords contains tWord) is true then
answer "Yes, it is!!"
else
answer "no, sorry..."
end if
end mouseUp
