;; concurrency.txt ;; ;; David Kauchak ;; ;; Examples of the different Handy Logo concurrency ;; features menu 1 [motor-demo] menu 2 [motor-demo2] menu 3 [motor-demo3] menu 4 [motor-demo4] menu 5 [motor-demo5] menu 6 [good-motor] menu 7 [bad-motor] global [songon] ;; a couple of procedures that try and change ;; the direction of the motor based on a press of the ;; switch to bad-motor a, on loop[ waituntil [switch 7] a, rd ] end to good-motor a, on loop[ waituntil [switch 7] a, rd waituntil [not switch 7] ] end ;; some concurrency examples to motor-demo launch [good-motor] play-song end to motor-demo2 forever [ beep wait 10 ] good-motor end to motor-demo3 a, on when [switch 7] [a, rd] loop [ beep wait 10 ] end to motor-demo4 every 10 [beep] good-motor end to motor-demo5 every 10 [beep] launch [good-motor] when [switch 8] [ stoprules ] end to play-song setsongon 1 beethoven end to stop-song setsongon 0 end to beethoven loop[ wait 6 repeat 3 [play_note 90 1 1] play_note 86 7 5 repeat 3 [play_note 88 1 1] play_note 85 7 5 repeat 3 [play_note 90 1 1] play_note 86 1 1 repeat 3 [play_note 91 1 1] play_note 90 1 1 repeat 3 [play_note 98 1 1] play_note 95 7 5 repeat 3 [play_note 90 1 1] play_note 85 1 1 repeat 3 [play_note 91 1 1] play_note 90 1 1 repeat 3 [play_note 100 1 1] play_note 97 7 5 ] end to play_note :frequency :duration :wait if songon [note :frequency :duration wait :wait] end