LOGO-L> MicroWorlds buttons switch... 
Author Message
 LOGO-L> MicroWorlds buttons switch...


Thanks to everyone who offered help getting the button to switch from on to
off in MicroWorlds 2.0. One solution is to get the button to change its rule
state (dialog box) as it is clicked. Shown below is the program. Works well
as a toggle.

;newprojectsize [400 300]

to startup
;checks to see if the t1 is missing
if empty? get "page1 "turtles
        [newturtle "t1 set "t1 "rule [launch [wander] ] ]
cg pu st
setc "black
;used for checking the pen state
make "color 0
;creates the buttons
newbutton "button1 [-175 130] [start]
        set "button1 "size [45 22]
newbutton "button2 [-175 95]   [reset]
        set "button2 "size [45 22]
newbutton "button3 [-175 60] [draw]
        set "button3 "size [45 22]

to start
t1, clickon
;the magic...changes the rule for button1
if ( last get "button1 "rule )  = [start] [set "button1 "rule       [launch
[stopit] ] ]

to stopit
t1, clickoff
;flips it back
if ( last get "button1 "rule )  = [stopit] [set "button1 "rule      [launch
[start] ] ]

to wander
;keeps the turtle happy
if :color = 1 [setc random 140]
seth random 360
fd random 22

to draw
;puts the pen down...still don't know how to find out
;if the pen is down or up
ifelse :color = 0 [make "color 1 pd] [make "color 0 pu]

to reset
;clears it all off
make "color 0
setc "black


Sun, 23 Apr 2000 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. LOGO-L> Re: MicroWorlds Logo Assistance

2. LOGO-L> MicroWorlds Tools

3. LOGO-L> Shooting a rocket (MicroWorlds)

4. LOGO-L> slideshow (MicroWorlds)

5. LOGO-L> Deleting pages in MicroWorlds

6. LOGO-L> RE: MicroWorlds question

7. LOGO-L> MicroWorlds question

8. LOGO-L> Microworlds

9. LOGO-L> slideshow (MicroWorlds)

10. LOGO-L> Evaluation of ToonTalk versus MicroWorlds

11. LOGO-L> MicroWorlds platforms

12. LOGO-L> MicroWorlds web page


Powered by phpBB® Forum Software