on returninfield need any word to trigger then statement

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rpalmer
Posts: 3
Joined: Sat Oct 19, 2013 5:35 pm

on returninfield need any word to trigger then statement

Post by rpalmer » Sat Oct 19, 2013 5:53 pm

Hi,
I'm trying to write code so that when a user presses return in a field, if what was entered in that field is any word in a specific variable that contains multiple words, a then statement will be triggered. Currently the code is written so that when a user presses return in the field, the then statement will only be triggered if what was entered into the field matches exactly what is in the variable.

Currently the code looks like this-

on returninfield
if line 1 of me = varBrandname then
show field "correct"
add 20 to varWinScore
add 1 to gamePart
put the seconds into varEndTime
put false into varGameActive
ComputeScore

wait 2 seconds
hide field "correct"
show field "class label"
show field "classguess"
focus on card field "classguess"
put the seconds into varStartTime

else
show field "wrong"
wait 2 seconds
hide field "wrong"
put empty into me
focus on me
end if
put true into varGameActive
computeTime
end returninfield

Any thoughts or suggestions? This is my first time posting so I apologize for anything that does not make sense.

Thansk!

rpalmer
Posts: 3
Joined: Sat Oct 19, 2013 5:35 pm

Re: on returninfield need any word to trigger then statement

Post by rpalmer » Sat Oct 19, 2013 6:02 pm

I actually may have resolved the problem by using the operator 'is among'.

So, now it looks like

if line 1 of me is among the words of varBrandname then
show field "correct"
add 20 to varWinScore
add 1 to gamePart
put the seconds into varEndTime
put false into varGameActive
ComputeScore


If anyone has any feedback though, I would be glad to hear it!

Thanks!

Post Reply