[Newbies] Beginners questions

Ned Konz ned at bike-nomad.com
Wed Nov 8 20:15:51 UTC 2006

Jeff wrote:
> Hello group!
> I'm hoping that this beginners list is a good place for a beginner to 
> get answers to... well, beginner's questions. And so, with that in mind, 
> I'll ask a few questions. But first, experience has taught me that I 
> should be a little more clear in what I'm looking for as an answer. 
> Imagine a total newbie to computers asked a group of experts the 
> question "How do I run a program under windows?". One member of the 
> group decided to respond by handing him a 400 page technical manual on 
> windows and telling him that everything he wants to know is in there. 
> Upon seeing that the rest of the group decides that his question has 
> been answered and sees no need to offer additional assistance. This 
> newbie's question wasn't actually answered by the group, ultimately what 
> they did was say "ask the manual". The manual naturally can't hear him 
> so it can't directly respond to his question, he has to start searching 
> it. After skimming a bunch of pages and not seeing what he's looking 
> for, (or anything he understands), he looks in the index. It isn't 
> there. He looks in the table of contents to see a chapter called 
> "Getting started with windows". Thinking that looks like what he needs, 
> he flips to it and it starts out by telling him that the first thing he 
> needs to do is install windows. Ok, so he looks for this Windows disk. 
> That's strange, his computer didn't come with any windows disk. So next 
> he goes out and spends $800 on the latest version of windows. He brings 
> it home and spends 5 hours trying to follow the instructions for 
> installing it, but it isn't working. He wonders if he bought the wrong 
> version of windows or if maybe the disk is corrupted, (he read that 
> somewhere in the manual). Or maybe his computer is bad. In any case, he 
> finally decides never to touch a computer again out of frustration.
> The problem here was that the newbie didn't have enough computer 
> proficiency to understand the manual that was being handed to him. The 
> steps he took were logical, and he put a lot of effort and money into 
> trying to solve his question, which was how to run programs under 
> windows. What would have helped him better would be if someone in the 
> group had just told him to "double click it". He would have saved his 
> money, known a little more about computers than he ever learned through 
> the manual, and enjoyed PC ownership like the rest of us. So I guess 
> what I'm saying is I'm hoping to get answers like "double-click it". 
> Sorry if that sounds fussy, but I've gone through enough experiences 
> similar to that fictional newbie above that I felt I had to say 
> something. So if you're still reading, here are the questions. Actually, 
> this is pretty long, so I'll just ask one question for now.
> 1. In a workspace, I've typed the following...
> wonder := Wonderland new.
> copter := wonder makeActorFrom: 'Objects\Vehicles\Helicopter.mdl'.
> copter turn:'left'.
> So far, everything works fine. The wonderland and helicopter are 
> created, and I am able to send it messages to make it turn, move, etc. 
> Now I'd like to make it move by using the arrow keys. How do I do that?
> What I've tried so far = My first plan to try to do this was by using 
> tile scripts. I've done the race car tutorial, and I figured out how to 
> drive that around with the arrow keys once I looked in the world's 
> viewer and selected the input pane, which gave me access to the "world's 
> lastKeystroke" tiles. So, I made a tile script that used the 'test... 
> yes... no' box and put the world's lastKeystroke = <left> as the test 
> condition. Then I toggled the script to 'textual' and filled in the 
> following.
> script1
>     World1 getLastKeystroke = '<left>' "" false
>        ifTrue: [ copter turn: 'left']
> and it tells me it doesn't know what copter is. Come to think of it 
> neither do I. Is it a variable, a method, or something else? I've played 
> around with this a lot, and the only time I got the helicopter to turn 
> was when I scripted the whole...

What happened is that when you make a reference to an unknown name in a
Workspace, that it creates a "binding" between the name and an object in
its own local (private) lookup table. So the scope of 'wonder' and
'copter' is local to the Workspace. And they are variables.

If you want to be able to refer to your "copter" from a tile script, it
has to be visible to that script. There are several ways to do this.

There is a global namespace, called 'Smalltalk'. Most of what it
contains are classes, and by tradition the names in Smalltalk begin with
a capital letter.

To add your variables to this namespace, you could do:

Smalltalk at: MyWonderland put: Wonderland new.
Smalltalk at: MyCopter put: (MyWonderland makeActorFrom:

This will make true globals. However, there's now no automated way to
manage their lifecycle: to initialize them and deinitialize them when
the project is entered or exited, etc.

These variables could also be attached to a class as class variables.
Then you could use the existing startup/shutdown hooks called on any 
class that wants to be in the startup or shutdown lists.

Or you could attach these variables to a Morph so that you could script
it directly. The Morph could be kept offscreen (say in a Flap). You 
could then trigger a script on entering the world.

> script97
>     | wonder copter |
>     wonder := Wonderland new.
>     copter := wonder makeActorFrom: 'Objects\Vehicles\Helicopter.mdl'.
>     copter turn:'left'.
> but that doesn't really do what I'm trying to do.
> Thanks in advance and happy squeaking!
> Jeff
> ------------------------------------------------------------------------
> No banners. No pop-ups. No kidding.
> Make My Way your home on the Web - http://www.myway.com
> ------------------------------------------------------------------------
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

Ned Konz
ned at bike-nomad.com

More information about the Beginners mailing list