This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-06-24 22:03:30

aszy
Scratcher
Registered: 2007-06-24
Posts: 8

Has anyone been able to implement a simple stack mechanism...

Looking to keep track of moves or distances and would like to use a stack. Anyone pulled one off?
Thanks
Al

Offline

 

#2 2007-06-25 01:09:17

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Has anyone been able to implement a simple stack mechanism...

How big a stack?  For up to 5 or 6 deep, it is probably easiest to use multiple variables,
as in the RPN_calculator, which has a stack of 4 values:
http://scratch.mit.edu/projects/kevin_karplus/2164

If you need a bigger stack, you'll probably have to store the information as colored objects on the screen.  You're probably better off stamping tiny costumes than using the pen, as the pen is misaligned in the Squeak implementation:
http://scratch.mit.edu/projects/kevin_karplus/11090

Offline

 

#3 2007-06-25 13:04:18

aszy
Scratcher
Registered: 2007-06-24
Posts: 8

Re: Has anyone been able to implement a simple stack mechanism...

Thanks Kevin - looks like we were thinking along the same lines.
Al

Offline

 

Board footer