Code doesnt work as expected.
Posted: Thu Jan 08, 2015 10:59 pm
Sorry, i didnt know how else to title this.
Setup: This is for a quiz where there are 8 questions selected at random and knock out each number from the choice each spin
Elements. 8 fields with short name 1aa - 8aa , a button marked new and a button marked spin
First i setup an array of possible numbers 1 - 8 and reset all fld backgroundColors with the "new" button
New Button Code
when you click spin it will quickly flash the fld green randomly 10 times until the last random color goes red and that number is locked out of future selections. My problem is it doesnt flash green. The code looks fine to me. Did i miss anything?
Spin Button Code
Its answering the correct fld names but not changing their color to green within the repeat loop
Setup: This is for a quiz where there are 8 questions selected at random and knock out each number from the choice each spin
Elements. 8 fields with short name 1aa - 8aa , a button marked new and a button marked spin
First i setup an array of possible numbers 1 - 8 and reset all fld backgroundColors with the "new" button
New Button Code
Code: Select all
global ourArray
global ourArrayMax
on mouseUp
put 8 into ourArrayMax
put 1 into advan
put empty into ourArray
repeat for ourArrayMax times
put advan&return after ourArray
put advan&"aa"into nameofIt
set the backgroundColor of fld nameofIt to 255,255,255
add 1 to advan
end repeat
end mouseUp
Spin Button Code
Code: Select all
global ourArray
global ourArrayMax
on mouseUp
if the number of lines of ourArray <> 0 then
repeat for 10 times
put random(ourArrayMax) into theRandomNumber
answer theRandomNumber
put line theRandomNumber of ourArray into RandomSelection
put RandomSelection&"aa" into nameofIt
answer nameofIt
set the backgroundColor of fld nameofIt of grp "Quiz 1" to 0,200,0
wait 200 milliseconds
set the backgroundColor of fld nameofIt of grp "Quiz 1" to 255,255,255
end repeat
put RandomSelection&"aa" into nameofIt
set the backgroundColor of fld nameofIt of grp "Quiz 1" to 200,0,0
delete line theRandomNumber of ourArray
subtract 1 from ourArrayMax
end if
end mouseUp