referencing objects (newbie)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

referencing objects (newbie)

ed-22
Hi everyone,

I just downloaded Squeak two days ago, so far I love it.  I want to
use it to teach my little sister how to program.  But first I need
some help figuring out the basics.

How do I refer to objects I create?

If I create, for example, an EllipseMorph how can I refer to it in a
Workspace, so I can send it messages using "do it"?  I've figured out
how to open a Viewer and change the object's name, but if I try to
send it a message in a Workspace I get an "Unknown variable" error.

Thanks,

Eddie

Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

Francisco A. Lizarralde-2
Hi Eddie,

Try this

myEllipse := EllipseMorph new.
myEllipse openInWorld.
myEllipse color: Color blue

and you can continue sending messages to myEllipse and watching the
results.

Hope this helps.

Regards,

Francisco


El vie, 17-02-2006 a las 10:42 -0700, Eddie Hillenbrand escribió:

> Hi everyone,
>
> I just downloaded Squeak two days ago, so far I love it.  I want to
> use it to teach my little sister how to program.  But first I need
> some help figuring out the basics.
>
> How do I refer to objects I create?
>
> If I create, for example, an EllipseMorph how can I refer to it in a
> Workspace, so I can send it messages using "do it"?  I've figured out
> how to open a Viewer and change the object's name, but if I try to
> send it a message in a Workspace I get an "Unknown variable" error.
>
> Thanks,
>
> Eddie
>


Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

Joe Koberg
In reply to this post by ed-22
Eddie Hillenbrand wrote:

> Hi everyone,
>
> I just downloaded Squeak two days ago, so far I love it.  I want to
> use it to teach my little sister how to program.  But first I need
> some help figuring out the basics.
>
> How do I refer to objects I create?
>
> If I create, for example, an EllipseMorph how can I refer to it in a
> Workspace, so I can send it messages using "do it"?  I've figured out
> how to open a Viewer and change the object's name, but if I try to
> send it a message in a Workspace I get an "Unknown variable" error.
>
>  

You can create the EllipseMorph from the workspace and then you
have a reference to it:

       e := EllipseMorph new openInWorld. <Alt-D>
       e<Alt-P> an EllipseMorph(1873)

Then the variable "e" refers to the new ellipse.

The World morph is the "root" of all the morphs you see on the screen.
You can ask it for one of its children by name (the name you entered in
the viewer):

      e := World submorphNamed: 'BigEllipse'. <Alt-D>
      e<Alt-P> an EllipseMorph(1873)

(<Alt-P> of course means to press Alt-P to Print It)

You can also ask any class for all of its instances, which will return
a collection of them:

      EllipseMorph allInstances

However on my squeak this returns 83 separate EllipseMorphs,
probably not what you're looking for.




Joe Koberg
[hidden email]



Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

Yoshiki Ohshima
In reply to this post by ed-22
  Eddie,

> I just downloaded Squeak two days ago, so far I love it.  I want to
> use it to teach my little sister how to program.  But first I need
> some help figuring out the basics.
>
> How do I refer to objects I create?

> If I create, for example, an EllipseMorph how can I refer to it in a
> Workspace, so I can send it messages using "do it"?  I've figured out
> how to open a Viewer and change the object's name, but if I try to
> send it a message in a Workspace I get an "Unknown variable" error.

  How old is your sister?  You (she) may be able to do what she wants
just all with tile scripting.

  By the way, In the menu (accessible from the button on the left in
the title bar) of a Workspace, there is a checkbox called "create
textual reference to dropped morphs".  If you check it on, you can
drop a Morph onto the Workspace and get a variable definition for it.

-- Yoshiki

Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

Dan Corneanu
In reply to this post by ed-22
Eddie Hillenbrand wrote:
> Hi everyone,
>
> I just downloaded Squeak two days ago, so far I love it.  I want to
> use it to teach my little sister how to program.  But first I need
> some help figuring out the basics.

If you are preparing to teach someone then make sure she/he will have
fun or else there is much chance to bore her/him.

You can use E-Toys / User Scripting. You can create your morphs using
the 'Supplies' drawer or painting one yourself. Then just select it and
open it's halos (http://minnow.cc.gatech.edu/squeak/3546). Click on the
one with a little eye (open a Viewer for me). From here on you can start
building scripts for your morph.

Here are some good starting points:
http://www.squeakland.org/school/drive_a_car/html/Drivecar12.html
http://squeakland.org/whatis/tutorials.html

Of course there is also the old boring way of instances, references,
message selectors, variables etc.

Good luck !


> How do I refer to objects I create?
>
> If I create, for example, an EllipseMorph how can I refer to it in a
> Workspace, so I can send it messages using "do it"?  I've figured out
> how to open a Viewer and change the object's name, but if I try to
> send it a message in a Workspace I get an "Unknown variable" error.
>
> Thanks,
>
> Eddie
>


Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

stéphane ducasse-2
In reply to this post by ed-22
Hi

Have a look at
        http://smallwiki.unibe.ch/botsinc/
this is an environment exactly done for that on top of squeak :)....

Stef

On 17 févr. 06, at 18:42, Eddie Hillenbrand wrote:

> Hi everyone,
>
> I just downloaded Squeak two days ago, so far I love it.  I want to
> use it to teach my little sister how to program.  But first I need
> some help figuring out the basics.
>
> How do I refer to objects I create?
>
> If I create, for example, an EllipseMorph how can I refer to it in a
> Workspace, so I can send it messages using "do it"?  I've figured out
> how to open a Viewer and change the object's name, but if I try to
> send it a message in a Workspace I get an "Unknown variable" error.
>
> Thanks,
>
> Eddie
>
>


Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

ed-22
In reply to this post by Francisco A. Lizarralde-2
On 2/17/06, Francisco A. Lizarralde <[hidden email]> wrote:

> myEllipse := EllipseMorph new.
> myEllipse openInWorld.
> myEllipse color: Color blue

My next question was going to be "how can I make a morph
programatically."  Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

ed-22
In reply to this post by Yoshiki Ohshima
On 2/17/06, Yoshiki Ohshima <[hidden email]> wrote:

>   How old is your sister?  You (she) may be able to do what she wants
> just all with tile scripting.

She's eleven and quite advanced for her age.  She skipped ahead to 7th
grade this year and still manages nearly straight A's.  Consequently
she's gone from pre-algebra to algebra in one swift step.  She's
having trouble breaking the equations into small steps and doing them
sequentially.  I think teaching her some basic programming will be a
fun way to help her.

I think I'll start with tile scripting and if she shows interest I'll
begin showing her how to write the actual code.  At the very least I
want her to learn sequence, selection and repetition.

>   By the way, In the menu (accessible from the button on the left in
> the title bar) of a Workspace, there is a checkbox called "create
> textual reference to dropped morphs".  If you check it on, you can
> drop a Morph onto the Workspace and get a variable definition for it.

That works great thanks.

Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

Yoshiki Ohshima
In reply to this post by ed-22
  Eddie,

> > myEllipse := EllipseMorph new.
> > myEllipse openInWorld.
> > myEllipse color: Color blue
>
> My next question was going to be "how can I make a morph
> programatically."  Thanks.

  Not quite sure what you mean by "programatically", because the above
code creates an EllipseMorph programatically.

  In tile scripting, the "copy" tile makes a copy of receiver.  You
need to assign the result into a property or use it as an argument
ofor a command (or such).

-- Yoshiki

Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

Yoshiki Ohshima
In reply to this post by ed-22
  Eddie,

> >   How old is your sister?  You (she) may be able to do what she wants
> > just all with tile scripting.
>
> She's eleven and quite advanced for her age.  She skipped ahead to 7th
> grade this year and still manages nearly straight A's.  Consequently
> she's gone from pre-algebra to algebra in one swift step.  She's
> having trouble breaking the equations into small steps and doing them
> sequentially.  I think teaching her some basic programming will be a
> fun way to help her.
>
> I think I'll start with tile scripting and if she shows interest I'll
> begin showing her how to write the actual code.  At the very least I
> want her to learn sequence, selection and repetition.

  Sounds like a good idea.  EToys' expressive power is indeed limited,
but you can do pretty impressive things in eToys, definitely more than
a programmer in a typical language would imagine from the first look
how much it can.

  The Holder can hold many objects and has a cursor.  So these are
good basis for the sequence.  The "ticking" does provide basic
repetition.  If you put a small differential in a script and tick it,
you can effectively integrate the differentials.  This is pretty
powerful idea.

  You might want to join squeakland mailing list for more discussions
on the tile programming in eToys.

http://squeakland.org/mailman/listinfo/squeakland

-- Yoshiki

Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

ed-22
In reply to this post by Yoshiki Ohshima
On 2/21/06, Yoshiki Ohshima <[hidden email]> wrote:

> > > myEllipse := EllipseMorph new.
> > > myEllipse openInWorld.
> > > myEllipse color: Color blue
> >
> > My next question was going to be "how can I make a morph
> > programatically."  Thanks.
>
>   Not quite sure what you mean by "programatically", because the above
> code creates an EllipseMorph programatically.

I only meant that he answered a question I was planning on asking
before asked it.

Reply | Threaded
Open this post in threaded view
|

Re: referencing objects (newbie)

ed-22
In reply to this post by Yoshiki Ohshima
On 2/21/06, Yoshiki Ohshima <[hidden email]> wrote:

>   You might want to join squeakland mailing list for more discussions
> on the tile programming in eToys.
>
> http://squeakland.org/mailman/listinfo/squeakland

I joined the list.  Thank you, and thanks everyone else, for all the
friendly help.