[Squeakland] Problem with scope of objects
scott.wallace at squeakland.org
Mon Nov 12 23:56:27 PST 2007
I think that perhaps the "tutorial" you were looking at might not be
the best way to get started with etoys.
First of all, to get a classic "Hello World" built in a Squeak
project, there's no need to open a Viewer, nor to create or run a
script. If you want a project which, when loaded, displays the text
"Hello World" (this is the classic definition of a "Hello World"
program, I believe,) you can simply obtain a fresh "text" object from
the supplies flap, then click to select the word "text" and then type
to replace its contents with the words "Hello World". If desired,
resize the text object using the yellow resize handle. Then save the
project, and you're done. This is not a programming task, but rather
simply a get-to-know-the-environment task.
If for some reason you're intent on using a tile script to set the
contents of the Text object, rather than simply directly editing the
contents as described above, you can indeed pursue the approach
suggested in that tutorial. However, the tutorial's instruction that
you click the checkbox in the Scriptor's header to change it from tile
mode to textual mode seems to be what's leading you astray here.
There's no reason to go to "textual mode" -- the task at hand is
easily accomplished staying in tile mode, by simply text-editing the
word "Text" to the right of the arrow in the script into the wording
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 43278 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20071112/a0bf58b3/pastedGraphic-0001.tiff
-------------- next part --------------
Finally, I would guess that the problems you're having with object-
reference are because you are trying to refer to other objects by
typing their names into textual code in textual scripts. You should
really stick to tiles, particularly until you've mastered the basics
of tile scripting! In the case of the classic drive-a-car demo, when
you want "Car turn by 5" in a script to become "Car turn by Wheel's
heading", you open Wheel's Viewer, grab "Wheel's heading" tiles from
the Viewer, and drop them on the "5".
Also, you can use the orange "tile" handle in the halo of an object to
"tear off a tile" that refers to that object. Drop that tile onto any
reference tile anywhere in any script and it will replace that tile.
What you were trying to do was probably to type a textual script in
which you guessed at what the internal name used to refer to a
particular object might be -- but this is not a reliable approach,
since there is no restriction made on the format of external object
names, nor any requirement of uniqueness, with the result that Squeak
internally uses a regime of "internal names" which are syntactically
acceptable and unique, and there is no guarantee of correlation
between visible names and internal names.
So the bottom line is: use tile scripts rather than textual scripts.
Use drag-and-drop, rather than typing. All of the introductory etoys
materials that I'm aware of (other than the tutorial you ran across)
operate strictly with tiles. Textual scripting provides a great
"escape" which opens up the entire universe of Smalltalk programming
to the advancing user, but textual scripting certainly should play no
role in "Hello World", nor in "Drive a Car", nor in any other
If this does not properly address your concerns, please ask further!
On Nov 12, 2007, at 8:50 PM, Christian Bode wrote:
> I am german cs student getting more and more amazed about squeak.
> Tonight I began to play around a bit and wanted to do that amazing
> "draw and steer your car" thing :)
> I used this tutorial to get started:
> Well, unfortunately i could not figure out this simple thing in 3
> My problem is, after having added the car "Speedy" to the world, I
> reference to it from any other script. If I add a steerwheel to the
> world, and
> want attach a script to it, squeak is not able to resolve that
> reference. It will
> tell me that "Speedy" is undefined and ask me if I would like to
> it global or create it.
> I had this problem with all kinds of things; text fields, button
> etc. I could
> not manage to get the "Hello World", from the tutorial running
> Did I get something wrong ? So before I loose interest I rather ask.
> I am
> puzzled because I did it exactly the way described in the tutorial.
> Thank you a lot!
> Frederick (That?s a nick, if you wonder :))
> Squeakland mailing list
> Squeakland at squeakland.org
More information about the Squeakland