Working with Repeat Loops
Posted: Sat Jul 07, 2012 7:35 pm
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
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