[starlogo-users] asynchronous "ask-turtles"

Andrew Begel abegel at eecs.berkeley.edu
Fri Jun 25 19:12:22 EDT 2004


Instead of using ask-turtles to touch off asynchronous threads, try 
using forever buttons. Make a forever button for each thread that you 
want to do and then start and stop the forever button from your code. 
For example,

Make a forever button called "goes-forward" with code "fd 1". Then from 
a procedure, turn on the button for 5 seconds:

to run-my-project
startgoes-forward
wait 5
stopgoes-forward
end

start"buttonname" and stop"buttonname" return immediately, pushing or 
popping the forever button to start and stop those threads. So you can 
start as many buttons as you like.

Addressing your other concern, the only way to ask turtles to do 
something without waiting for them to finish is to hatch a turtle and 
give it a command to run:

to reproduce
hatch [ loop [fd 1] ]
hatch [ loop [bk 1] ]
end

That will make a baby turtle who will go forward 1 forever, and then 
immediately make a baby turtle who goes back 1 forever.

Andrew


On Jun 25, 2004, at 1:31 PM, Buck, Peter M wrote:

> Hello to the list from a new subscriber.
>
> Please forgive my impertinence in posting without waiting to listen 
> for a while.  At least I did check through the last 8 or 9 months of 
> archives (wouldn't a search capability be nice!) and didn't see this 
> topic mentioned.
>
> I was dismayed to discover that "ask-turtles" is apparently not 
> asynchronous--does not go on to the next step until the turtles have 
> completed whatever you were asking them.  While I can imagine that 
> such behavior would be useful part of the time, surely the ability to 
> touch off several infinite loops would also be useful.  I found that 
> you COULD accomplish the deed by touching off one procedure from which 
> control was passed to various infinite loops depending on breed, but 
> either I'm totally missing the boat or this seems like capability 
> crying out to be implemented.  Which is it?
>
> - Peter Buck
> _______________________________________________
> starlogo-users mailing list
> starlogo-users at media.mit.edu
> http://education.mit.edu/mailman/listinfo/starlogo-users




More information about the starlogo-users mailing list