[Back to GSN Home Page] [Back to Message Index]

Global SchoolNet - Automated Message Archive

Re: LOGO-L> MicroWorlds Query: random setpos?




Michael Tempel (michaelt@media.mit.edu)
Sat, 3 Feb 1996 11:29:56 -0500

>Thank you, Dan, for your help with my textbox question. I would like to
>pose another to the list:
>
>I'm trying to send a turtle (or multiple turtles) to random positions on
>the screen. Here's the best I could figure:
>
>setpos [random 250 random 250]
>
>This doesn't work because setpos only gets one input.
>
>I'm sure the solution lies in an extra set of parentheses or brackets.
>
>My students and I appreciate your help.
>
>Bill Donaldson
>Public School 11
>NY, NY

This will work:

setpos list random 250 random 250

The two RANDOM procedures each report a number somewhere between 0 and 249.
LIST uses these two number as inputs and reports a list of the two numbers
to SETPOS, who is then happy and tells the turtle where to go.

The reason

setpos [random 250 random 250]

doesn't work is that stuff insude brackets isn't "evaluated", that is the
RANDOM procedures aren't run.

(If it did work the way you wanted it to then

PRINT [FORWARD 100]

would cause the turtle to move.)

-Michael

Michael Tempel tel: 212 765 4918
Logo Foundation fax: 212 765 4789
250 West 57th Street michaelt@media.mit.edu
New York NY 10107

---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org. Mail
questions about the list administration to logofdn@gsn.org. To
unsubscribe send unsubscribe logo-l to majordomo@gsn.org.