Answer dialog disrupts wait command

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
MisMel
Posts: 7
Joined: Thu Dec 13, 2012 11:12 pm

Answer dialog disrupts wait command

Post by MisMel » Thu Dec 13, 2012 11:32 pm

Hi all. I need some help getting my program to wait a certain amount of time, allowing input from the user during that time, and then respond to the input. For example, I want the user to do math problems for 30 seconds, and after they submit their response for each math problem, I want a dialog box to tell them whether their response is correct. The problem is, when I use the "answer" command, it cancels the wait period and automatically moves on in the program. To illustrate what I want, here is some of my code:

Code: Select all

go to card "MathTest"
wait 30 seconds with messages
go to card "EndTest"
Then, in the card which I have called "MathTest," there are some math problems, with answer fields. Here is the script associated with one of those fields:

Code: Select all

on returninfield
   put field "ans1" of card "math" into tans
   if tans = (142) then
      answer "Correct!"
   else
      answer "That is incorrect. Please try harder next time."
   end if 
end returninfield
No matter how much time has passed, as soon as they click "Ok" in the Answer dialog box it moves on to the card "EndTest." Is there some option for using an Answer dialog box without canceling out the Wait command?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Answer dialog disrupts wait command

Post by Mark » Thu Dec 13, 2012 11:43 pm

Hi,

That's right, the answer dialog contains a bug that kills wait commands with messages. You can use the send command instead.

Code: Select all

go cd "MathTest"
send "goEnd" to me in 30 secs

on goEnd
  go cd "EndTest"
end goEnd
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

MisMel
Posts: 7
Joined: Thu Dec 13, 2012 11:12 pm

Re: Answer dialog disrupts wait command

Post by MisMel » Sat Feb 02, 2013 11:51 pm

I did not see your reply until now. Thanks, Mark!!

Post Reply