Hi Craig
Am I correct in presuming possibles, currentDigit , currentButton and otherButton are variables?
If so is there any reason why they are not called tPossibles, tCurrentDigit, tCurrentButton and tOtherButton? So far I have only come across variable with t in front of them. Is this significant?
Oh are variables and temporary variables different? Eek
This is what I think is happening in the code. Am I correct?
put "0,1,2,3,4,5,6,7,8,9" into possibles --This randomly assigns 0-9 to possibles
put any item of possibles into currentDigit -- This randomly assigns any digit in possibles to currentDigit
delete item currentDigit + 1 of possibles -- why + 1? --hmm I know what it is doing but am not sure why it is doing it. It stops the same digit appearing on B1 and B2. When I make it +2 it is possible to have the same number on B1 and B2 and when I take +1 out it is also possible to have the same number on B1 and B2. Am confused if currentDigit is the one that is to be matched then why is it currentDigit +1 rather than currentDigit that gets deleted from possibles? I have even had a look in the variable watcher. I guess there is a really simple answer to the question but it is eluding me at the moment
set the label of btn "testNumber" to currentDigit -- This sets the button “testNumber” label to currentDigit
put any item of "1,2" into currentButton
if currentButton = 1 then put 2 into otherButton else put 1 into otherButton
-- These two lines randomly assign B1 or B2 to be the correct answer
set the label of btn ("B" & currentButton ) to currentDigit
set the label of btn ("B" & otherButton ) to any item of possibles
-- These two lines sets the labels of B1 and B2 but how come they are referred to as B rather than B1 or B2? Does referring to them as B mean you refer to both or either? What does the & do it’s not in the dictionary
I did not use a label field. I wonder why? I am afraid I have no idea?
Hi Craig and Dixie
I have taken bits of both of your code and have come up with this:-
Code: Select all
on mouseup
Set itemDel to tab
put the cNumberPairs of this card into thePairs
sort lines of thePairs by random(the number of lines of thePairs)
Set the label of button "ButtonL" to item 1 of line 1 of thePairs
Set the label of button "ButtonR" to item 2 of line 1 of thePairs
put item 1 of line 1 of thePairs into thePairsL
put item 2 of line 1 of thePairs into thePairsR
put any item of "1,2" into thePairsLorR
if thePairsLorR = 1 then set the label of button "testNumber" to thePairsL
if thePairsLorR = 2 then set the label of button "testNumber" to thePairsR
end mouseup
The first part sort of works where I get data from cNumberPairs to show in ButtonL and ButtonR, I say sort of works because it doesn’t work if I click either of ButtonL or ButtonR but it does work if I click anywhere else. I thought that if there was no code on the button then the message would be passed up to the card?
The next bit to not work is the bit where I try to get testNumber to randomly match ButtonL or ButtonR
Have learned quite a bit I think but further help would be appreciated
