I’ve built an application in Livecode where there are nine buttons on a card. Eight of the buttons play short music samples and have a variable that holds the number of times the button was pushed. Holding down the mouse button allows the buttons to be dragged around the card as well. The ninth button starts a script that surveys the variables associated with the eight sample buttons and ensures that all the samples have been listened to at least once. The script puts the eight variables into one variable and then checks to see if they are empty. If they are, the script returns an error message prompting them to make sure they have listened to all the samples. The problem I’m having is that this works for all but one of the buttons – the one associated with variable gVar08. If this button has not been pressed, gVar08 remains empty and does not trigger the error message. I can’t figure out why. The scripts associated with the sample button and the evaluation button are provided below.
#Code for music sample button
global gVar08
on mouseDown
wait 30
if the mouseClick then
play audioClip "samples/C1/C1-8ConcertoForViolinStringsAndHarpsichordInGR202IAllegroMolto.wav"
set the filename of image "icn08" to "icons/if_abstract_symbol-03_1571964a.png"
add 1 to gVar08
else
grab me
end if
end mouseDown
#Code assigned to 9th button: Check to see if all samples played at least 1x
global gVar01, gVar02, gVar03, gVar04, gVar05, gVar06, gVar07, gVar08, gErr01
local sClct
on mouseUp
put gVar01, gVar02, gVar03, gVar04, gVar05, gVar06, gVar07, gVar08 into sClct
repeat for each item local in sClct
if local = "" then
answer "Have you listened to all of the samples? Be sure to play them all."
add 1 to gErr01
break
end if
end repeat
end mouseDown
You need a comma and “” after gVar08 in the list. When it is empty, the list ends with 7. Adding a this should always include the last value even if empty.