Page 1 of 1

Making quiz app score

Posted: Tue Jul 02, 2013 11:13 am
by totalnoob
Hi im new in livecode and i want make quiz app.
my code looks like

Code: Select all

on pickQuestion
  put 1 into currentQues
  put line currentQues of fld "questions" into qLine
  put item 1 of qLine into fld "Field"
  repeat with i = 2 to 5
    put "Answer" & i - 1 into fieldName 
  set label of btn "Answer1" to item i of qLine
 set label of btn "Answer2" to item 2 of qLine
 set label of btn "Answer3" to item 3 of qLine
 set label of btn "Answer4" to item 4 of qLine
end repeat

   
                
end pickQuestion
everything working fine but i want create some kind of score but dont know how can someone help me ?
i was trying to add score label with
on mouseUp
go to next card
add 10 to the field "Score"
end mouseUp
but it doesnt show same score after few cards even this
put number of fld "score" of card "card2" into fld "score" of card "card3"
doesnt working
thanks

Re: Making quiz app score

Posted: Tue Jul 02, 2013 11:56 am
by shaosean
Just curious about a couple of things..

Code: Select all

  repeat with i = 2 to 5
    put "Answer" & i - 1 into fieldName  --put field name into a variable
How come you are looping with 2 to 5 and then subtracting 1 on the next line? Why not just loop with 1 to 4?

Code: Select all

  set label of btn "Answer1" to item i of qLine
With your original script, your "Answer1" button will always be the same value as one of the other Answer buttons.. Is this what you are looking for?

Code: Select all

on mouseUp
  go to next card 
  add 10 to field "Score"  -- no need for "the" before field
end mouseUp

Code: Select all

put number of fld "score" of card "card2" into fld "score" of card "card3"
The "number" of the field is a special property and will not give you what you think it will.. Just refer to "the text" of a field and Rev will convert it to a number if it is a number..

Anything else, feel free to ask (your code is looking good, just a few little gotchas ;-) )

Re: Making quiz app score

Posted: Wed Jul 03, 2013 9:44 am
by totalnoob
thanks
but i dont know why its not working i allways must go to card script and click F5 it doesnt change immediately do you know why ?

Re: Making quiz app score

Posted: Wed Jul 03, 2013 11:22 am
by shaosean
If you want to arrange for a TeamViewer session, email me < support AT shaosean DOT tk > and I would be more than happy to check it out for you..