Yet another question that will likely have an obvious answer...
I am trying to present a list of words, one by one, and have the user able to put a definition for each word. When the user clicks next, I want to evaluate whether or not the answer given matches the definition stored in the variable. Whether it is true or not, I want the repeat loop to continue through the list of words. What I have right now is as follows:
put field "Words" of card "Materials" into gMaterials
repeat with x=1 to the number of lines in gMaterials
put item 1 of line x of gMaterials into field "Word"
focus on field "Answer"
wait until gAnswer is not empty with messages
if gAnswer=item 2 of line x of gMaterials then
answer "Well done!"
else if gAnswer<> item 2 of line x of gMaterials then
answer "That is incorrect."
put line x of gMaterials &cr into gTryAgain
end if
end repeat
And the text in the answer field is put into gAnswer when the user clicks a button on the card called 'next'. Right now it keeps stopping at 'wait' point in the script, after I press the 'next' button. It puts the text into gAnswer, but doesn't continue through the rest of the script.
Any help would be much appreciated! Thanks!
-Laurel
Working with Repeat Loops
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Working with Repeat Loops
Hi,
A couple of observations.
Never name your objects with the likes of "word" or "answer".
Just don't.
I see in your code that the variable "gAnswer" is not ever populated. It will always contain its default contents, which is "gAnswer".
You cannot ever get past that. Was it filled with something from earlier code that was missing from the snippet you gave?
Write back...
Craig Newman
A couple of observations.
Never name your objects with the likes of "word" or "answer".
Just don't.
I see in your code that the variable "gAnswer" is not ever populated. It will always contain its default contents, which is "gAnswer".
You cannot ever get past that. Was it filled with something from earlier code that was missing from the snippet you gave?
Write back...
Craig Newman
Re: Working with Repeat Loops
I will change gAnswer once I figure out the problem. Thanks for the tip.
I have the text from one of the fields put into gAnswer on mouseup of a button on the card. I thought that could be pressed while I told the script to wait, as long as I had the 'with messages' in there. Does that not work?
Sorry, again, super new at this.
-Laurel
I have the text from one of the fields put into gAnswer on mouseup of a button on the card. I thought that could be pressed while I told the script to wait, as long as I had the 'with messages' in there. Does that not work?
Sorry, again, super new at this.
-Laurel
Re: Working with Repeat Loops
If you send a message explicitly with parameters, yes:
Send "yourMessage someParam" to this card. The parameter will be passed with the message, and its value can be read in the target handler.
Otherwise the value must be re-read in some way, either from a global variable, a script local variable or a custom property, as possible vectors.
Craig Newman
Send "yourMessage someParam" to this card. The parameter will be passed with the message, and its value can be read in the target handler.
Otherwise the value must be re-read in some way, either from a global variable, a script local variable or a custom property, as possible vectors.
Craig Newman
Re: Working with Repeat Loops
Thanks for your help!