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: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: MIA, Ask an Expert: Global Variable Value always the same
From: askanexpert@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 21 Nov 2011 11:19:57 -0700

This is an automatic message sent from the web form at:
http://mia.openworldlearning.org/mwforum.htm

from: Fabserl <Fabi_1990@xxxxxx>
date: Mon Nov 21 11:19:57 2011
platform: PC
version: MicroWorlds Ex

Hello ;)

The question belongs to the following code:

___________________________________

to begin

lt 40
make "a 130
wendeltreppe :a

end

to quadrat :a

repeat 4 [fd :a rt 90]

end

to wendeltreppe :a

quadrat :a 
lt 10
make "a :a - 2
if :a < 70 [stop]
wendeltreppe :a

end

__________________________________

Everything is fine with this code (main procedure is "begin"). But in the 
definition of global variables it says that they keep their value, even if the 
procedure is finished. So far so good. In the code, I create the variable with 
make "a 130. But if you look at the procedure "Wendeltreppe", a gets smaller 
and smaller every time (with make "a :a - 2). So at the end, the value of a 
should be something over 70. But if I type in in the command center Show :a 
after the procedure is finished, it gives the value 130. Why? "A" should be 
smaller than 130, because it changed during the 3 procedures.

Thank you for your responses!

Fabserl



  • Previous by thread: It's Not Too Late to Learn How to Code
  • Next by thread: Re: MIA, Ask an Expert: Global Variable Value always the same

  • 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