Undefined value and PlaySound

xristos pazol shared this question 4 years ago


I re-created a simple puzzle that we have in our Math book. If the correct answer (number) is placed in the input box the number turns green and a correct sound is heard, if the number is wrong it turns red and a false sound is heard. When the puzzle is completed a text box appears to show that it's correct. I also created a reset button in order to reset all numbers to undefined ? and start over. In order to do that I used the if command in every input box properties. For example number 3 is the correct answer, in scripting ,on update I put these statements

If[a ≟ ?, PlaySound["#HCh4BKFa"]] this statement in not working

If[a ≠ 3, PlaySound["#RskKN4HU"]] this statement is working fine

If[a ≟ 3, PlaySound["#umhEKbkN"]] and this is working fine

My problem is that when everything resets to ? I hear also the wrong sound 7 times as many as my input boxes which is very annoying :( Any help will be appreciated

Thank you in advance

Here is my file if you want to see it


Comments (2)


a==? is ever false. try to use ¬isdefined[a] instead



Thank you ! I solve it by using instead of If[a ≠ 3, PlaySound["#RskKN4HU"]] those two statements

If[a > 3, PlaySound["#RskKN4HU"]] and If[a < 3, PlaySound["#RskKN4HU"]] but your way is much more better :)

See my corrected files here



© 2021 International GeoGebra Institute