Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: "MicroWorlds Forum" <mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: variables or procedure inputs
From: "Daniel Ajoy" <da.ajoy@xxxxxxxxx>
Date: Fri, 06 Jan 2012 10:54:59 -0500

On Fri, 06 Jan 2012 10:45:10 -0500, Rotem Kimchi <rotemk2@xxxxxxxxxxxxxxxx> wrote:

if you want distance to be a variable you need to add ":" to the distance
variable

to start
make "distance 10
tto "t1
make "distance spi :distance
end

to spi :distance
forward "distance
rt 90
op :distance + 10
end

Or just:

to start
tto "t1
spi 10
end

to spi :distance
forward :distance
rt 90
spi :distance + 10
end

Rotem, notice that here "distance" is not really a variable, like the ones handled with "make".

In this case "distance" is really the input of a procedure. Those are two different kinds of "variables".


Try this:

to start
make "variable 10

show "outside.before
show :variable

manipulate :variable

show "outside.after
show :variable
end

to manipulate :variable

show "inside.before
show :variable

make "variable :variable + 1

show "inside.after
show :variable
end


I think you will be surprised to see what the last result is 10.

Daniel
OpenWorld Learning



  • Previous by thread: Re: MIA, Ask an Expert: Syntax err with recursive call
  • Next by thread: Re: variables or procedure inputs

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2008