;; menus_and_loops.txt ;; ;; David Kauchak ; this is how you add commands to the menu: menu 1 [beep-while-pressed] menu 2 [beep-slow-fast] menu 3 [beep-on-off] ; beep while switch 7 is pressed: to beep-while-pressed loop [ if (switch 7) [ beep ] ] end ; beep fast when switch 7 is pressed, ; slower otherwise: to beep-slow-fast loop [ beep ifelse (switch 7) [ wait 1 ; short pause ][ ; else wait 3 ; long pause ] ] end ; turn on beeping when switch 7 is ; pressed, turn it off with switch 8: ; use global variable "laston" to remember ; whether we're currently beeping global [laston] to beep-on-off loop [ if (switch 7) [ setlaston 1 ] if (switch 8) [ setlaston 0 ] if (laston = 1) [ beep ] ] end