Project Folders
Teacher Resources
Student Resources
How Do I?
Site Map
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:

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


to quadrat :a

repeat 4 [fd :a rt 90]


to wendeltreppe :a

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



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!


  • 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