[Newbies] Re: Morph import corrupted

Jerome Peace peace_the_dreamer at yahoo.com
Mon Jan 19 02:35:51 UTC 2009


[Newbies] Morph import corrupted


Hi Mark, Hi David,

This doesn't look like a squeak bug.

Mark, squeak and morphic can do some pretty remarkable things. You need to approach this as a foreigner in a new country. The best way to get the natives to do what you want is to learn the language they use to do it. (By natives I am talking about the objects in squeak, morphs included and in particular.)
The alternative is to invent new language as you go along. Which is the fun part. What you ran into is that saving a morph does not  save the extra language you made. So squeak was noisily trying to tell you it no longer understood what you thought you were saying.
The cure can be twofold. When I am developing in squeak I end my sessions by saving the project to disk and when asked say yes to saving the change set associated with the project. This will save all the morphs I have in the project and all the new and modified language that I created.
This will load into any image that is close to what you started with.
The other ways to save the language is to go to the class, or method you want to save, get a menu for it and request 'file out'. That will save as little as one method. By selecting the category the method is in you can save a bunch of methods. By selecting the class all of the methods connected with that class.
The other thing you can do is save all of the methods associated with your project. The tool to do that is the dual change sorter. There is a single change sorter but the dual sorter has the very useful feature of allowing you to copy or move the methods of interest in and out of any change set.
Again the file out menu command will save everything in the change set. This is usually what you want to bring to a new image. It is exactly what code you saved when you saved the project. The advantage of saving the change set separately is that it will travel better into foreign lands than the whole project.
The other thing the change set allows you to do is to write a preamble. I use this all the time to comment the code. So the forgetful me who reads it a month from now will remember.
The second fold of the cure is to be humble and to learn the native language from the natives. This is not as easy as going of and making your own. It is very important. Squeak will do thing in ways that will surprise you. And if you go about finding the reusable code first you will build up a useful set of ideas. You will be able to talk to the natives (objects) like one of their own. :-)

A good place to start is the World menu Objects tool. These contain different morphic widgets.
Grab one out. Halo click on it and select the monkey wrench handle. This gives a list of interesting ways to explore the morph. The object explorer is one of the most useful for looking at the morph itself. An object inspector gives a better ability to modify the object on the fly.
The other useful thing to do is ask to browse the morph class. This gets a code browser that allows you to see all the methods defined in the class.

I could go on but I'd better stop before I write a small book in the email.

>From your note I suggest you look in the collection classes. In particular, OrderedCollection can act as a stack for most purposes #addLast and #removeLast replacing push and pop. The other thing to look at is any morph that looks like it already does something close to what you want. That's usually a good starting point for discovering how to do things in the native tongue.

Hth,

Yours in curiosity and service, --Jerome Peace

======Previously:
Dave and Mark wrote:

David Mitchell david.mitchell at gmail.com 
Sun Jan 18 18:42:24 UTC 2009 
I don't use Morphic scripting, but I've played around with it. That section
of Squeak is eToys and the Squeakland distribution is the primary team
supporting eToys. Not that your question isn't OK here, but you may find
more experts there.

I don't know if loading/saving morphs is supported by anyone in the base
distribution.

On Sun, Jan 18, 2009 at 10:34 AM, Mark Carter <mcturra2000 at yahoo.co.uk>wrote:

> I'm new to smalltalk and squeak - and I must say, it seems capable of doing
> some pretty amazing stuff.
>
> I started playing with morphs today. I created a Stack (which I called
> BlogStack), which has a TextBody (actually a scrolling text morph) and a
> button.
>
> The button activates the following script when I mouseUp on the button:
>
> printBody
>    | |
>    TextBody setCharacters: 'Enter text here' .
>
>    ^ self
>
Where did you define #printBody? In what class is it known. What specifically did you do to set up the mouse up action? 

I may not be getting something. Right now I do not know how to recreate what you did.

> OK,  printBody is a bad name, but let's not worry about that. The basic
> idea is that you press the button, and it replaces the TextBody text with
>  'Enter text here'. So far, everything works as I expect.
>
> Now, I saved my stack morph from one image, and I wanted to see if I could
> load it in another. It loaded OK, but when I pressed my button, it
> complained:

>
> I am using Squeak 3.9 update #7067 for both the imported and exported
> morph.
>
> Curiously, if I open up the viewer on TextBody, I can toggle through most
> of its categories (basic, scripts, and so on), but it throws an exception if
> I try to go to 'colour & border' or 'text'. What's going on? Is it a bug?
>
Ok. That seems odd. It isn't possible to say whats happening w/o more informaitin.
You need to explain in detail how to recreate the problem. My guess is that it is because TextBody is not a normal morph and is using language you have not taught the current image. Of course it could always be a bug for another reason. Hard to know.


> Should I expect morphs to work across images? What about if I upgrade
> squeak - what's the chance that I'll still be able to load my morphs?

Reasonable. Assuming you load the special language for your morph into the image. See above.

Sometimes it will be necessary to update or modify things. Making things in squeak is a little like making sandcastles on a beach.

You can always choose to selectively upgrade the image you have to remain compatible.

The release process for this branch of squeak is not steady or too predictably. We rely on willing members of the community. It is a lot of work. The releasers catch all the flax of those who wish things had been done differently. The result is a high turn over amoung release teams and sharp shifts in goals and focus.

The excitement is that squeak is a good place to innovate. The Seaside folks know that. And if you are willing to roll up you sleaves squeak can be made to do amazing things in short periods of time. What is is not good at is giving highly polished results. 

> Also, is there any way that I can create a class, or gain access to,
> BlogStack, say by doing something like:
> b := BlogStack .

If you do that in a workspace it should work. If BlogStock is the name of a class you probably need to do something like
b := BlogStock new. That creates and instance of the class Blogstock.
then sending messages to b are the same as sending them to the instance.
Browse BlogStock and look at the creation method on its class side.
Look also at the methods it inherits from its superclasses.

> Would you advocate actually creating GUIs programmatically? It seems a
> safer bet, although rather more tedious.
>
Depends on what you need to do. I have found the Etoys and scripting can only go so far. When you get to that wall its time to look at the smalltalk programming environment. Which is what we have been discussing here. 

>
>




      


More information about the Beginners mailing list