alice-teacher Global Variables s Digest, Vol 39, Issue 1
Robert Durtschi
robert.durtschi at gcsu.edu
Thu Oct 3 06:38:25 EDT 2013
If you are using Alice 2.3 you can make a "global" variable by putting it in the World Properties tab.
Click on World in the object tree then click on the properties tab.
Use the create new variable button. In my quick test to make sure it works I created a new number variable named globalVar =1
I added a bunny object and dragged "bunny turn left" into the edit window.
When it asked for "amount" I chose "expressions"
The only choice at that point was world.globalVar
To set the varible
click on world in the object tree
from the properties tab drag globalVar into the edit window.
This can also be done from within a method in the bunny object. I created a bunny.turn() method and dragged the instructions into its edit window.
Here's the relevent code:
Methods
world.my first method ( )
No variables
bunny turn left globalVar revolutions
world.globalVar set value to 0.25
bunny turn left globalVar revolutions
bunny.turn
bunny
Methods
bunny.turn ( )
No variables
world.globalVar set value to 0.5
bunny turn right globalVar revolutions
Hope this helps
Bob Durtschi
--------------------------------------------
Message: 5
Date: Tue, 1 Oct 2013 10:20:50 -0400
From: Don Slater <dslater at andrew.cmu.edu>
Subject: Re: alice-teacher Declaring global variable
To: Alice educators <alice-teachers at lists.andrew.cmu.edu>
Message-ID: <9330FD9F-4B85-49A5-83D0-D3907CE920D6 at andrew.cmu.edu>
Content-Type: text/plain; charset=windows-1252
Which version of Alice are you using?
If you are using Alice 3.1, download the latest version now available on the web site? Earlier versions did not provide access to these variables, but that has since been fixed?
Later,
Don Slater
On Oct 1, 2013, at 10:08 AM, Nalini Ujre <nalinir54 at gmail.com> wrote:
> Hello,
>
> One of my students has created a project which requires a global variable since it will be accessed and updated from different procedures. I wanted to know how to declare a global variable. We tried using "scene property". It can be accessed from any procedure but unable to update it.
>
> Any help would be appreciated.
>
> Thanks,
> Nalini.
> _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
------------------------------
_______________________________________________
alice-teachers mailing list
alice-teachers at lists.andrew.cmu.edu
https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
End of alice-teachers Digest, Vol 39, Issue 1
*********************************************
More information about the alice-teachers
mailing list