Homework #1

An Introduction to the Squeak World



Based on Introduction to Squeak by Harry Porter
Version 1.0, 17 April 2001, by Andrew P. Black,
black@cse.ogi.edu
Further hacked on 7 January 2002, by Harry Porter,
harry@cs.pdx.edu

Your Name: _____________________________________

Date Due: 14 January 2002

Please write directly on this handout and turn it back in. Go through every step below. As you do each thing, place a check mark next to it to indicate that you actually did it. Fill-in answers where a blank line is provided.

Getting Started

Download the SQUEAK Software and put it on your computer. The software is available at www.squeak.org.

The necessary files are:
    Squeak 3.0Alpha8MT -- This is the Virtual machine, the application program.
    Squeak3.0.image    -- This binary file contains the initial collection of objects
    Squeak3.0.changes  -- This text file contain more source code
    SqueakV3.sources   -- This text file contains distributed Smalltalk source code

To start up the system, run the VM on the "image" file. In the Macintosh, this is done by double clicking on the "image" file. Later you will create your own "image" and "changes" file, but you will always use the "VM" and the "sources" files.

Using the Mouse

Smalltalk, from which Squeak is derived and with which it is still somewhat compatible, was designed assuming a three-button mouse. If your mouse has fewer buttons, you must press extra keys with the mouse button or buttons to simulate the mouse buttons that you are missing.

For platform independence, the mouse buttons are usually referred to by colors in the Squeak software and documentation. Consider buying a 3-button mouse; they are quite inexpensive, and make the Squeak world much more friendly. (They are pretty useful in many other applications too!) Software that comes with the mouse, or that is available on the Internet, will let you set up the buttons so that they do the right things. The following chart shows what keys must be held down when mouse-clicking to simulate Squeak's buttons.

Symbolic

MacOS

Windows

3-button

Use

Red

Mouse button

Left-button

Left-button

Selecting, moving the insertion cursor

Yellow

Option-button

Right-button

Middle-button

Application-specific menus

Blue

-button

Alt-Left-button

Right-button

Window and graphics manipulation

My mouse also has a scrolling wheel. I have this set up so that "wheel up" maps to -upArrow (on my Macintosh) and "wheel down" maps to -downArrow. This lets me use the wheel to control scrolling in my Squeak windows.

One of the advantages of referring to the buttons by colors is that you may choose to map them to different physical buttons from those shown above. For example, if you are left-handed, you might choose to reverse the red and blue buttons. On my mouse, the middle button is actually the scrolling wheel. Because the yellow button is used very frequently, I prefer to put the yellow button on the right, and to put the blue button on the wheel in the middle.

Placing some colored labels on the mouse buttons will help your fingers to follow these directions.

The World Menu

Red-click outside of any window; you will see the world menu. Notice that most Squeak menus are not modal; you can leave them on the screen for as long as you wish by selecting keep this menu up. Do this. Also, notice that menus appear when you click the mouse, but do not disappear when you release it; they stay visible until you make a selection, or until you click outside of the menu. You can even move the menu around by grabbing its title bar.

Bring up the open... submenu and select workspace. You should get a large window labeled Workspace.

Terminating and Restarting a Squeak Session

A Squeak session is normally terminated by writing out all of your objects to a disk file called a snapshot or image file. When you first start Squeak, the Squeak Virtual Machine is loaded with an initial set of objects, which includes a vast amount of pre-existing code and programming tools (all of which are objects). You will modify these objects during your Squeak session.

When you terminate Squeak, you will save a snapshot of your memory containing all of your objects. The next time you use Squeak, memory will be reloaded from this file and the state of the system will be exactly as you left it. The snapshot file will be named xxxxx.image, where xxxxx is something you will choose, like YourName.image. There will be a corresponding "changes" file, with a name such as YourName.changes.

Collapse and / or close unneeded windows

Each window has a title bar with a "close" icon (an x) in the upper left and a "collapse" icon in the upper right.

Workspaces

Graphics Demonstrations

Accessing Files

File Creation and Removal

Forms and Points

Forms are rectangular blocks of pixels, like mini-bitmaps.

Using a System Browser

The System Browser is the main tool used to read and write code in Smalltalk. It is OK to have many System Browsers open at once. Normally, if you change code in one Browser, the changes will be visible in any other. (Preferences >> smartUpdating controls this).

Executing Code: Sending Messages to Objects

Comments

Do you have any comments about this script? For future reference, were any instructions unclear/frustrating (which ones)?

______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

What if you Crash Squeak?

It is quite possible to crash Squeak—as an experimental system, Squeak lets you change anything, including things that are vital to make Squeak work! For example, try Smalltalk := nil.

The good news is that you need never loose work, even if you crash and go back to the last saved version of your image,which might be hours old. This is because all of the code that you executed is saved in the changes file. All of it! That includes one liners that you evaluate in a workspace, as well as code that you add to a class while programming.

So here are the instructions on how to get your code back. There is no need to read this until you need it. But when you do need it, you'll find it here waiting for you.

In the worst case, you can use a text editor on the changes file, but since it is many megabytes in size, this can be slow. Squeak gives you better ways.

How to get your code back

Restart Squeak, and select help>>useful expressions from the world menu. This will give you a workspace full of useful expressions. The first three,

Smalltalk recover: 10000.
ChangeList browseRecentLog.
ChangeList browseRecent: 2000.

are most useful for recovery.

If you execute ChangeList browseRecentLog, you will be given an opportunity to decide how far back in history you wish to browse. Normally, it's sufficient to browse changes as far back as the last Snapshot. (You can get much the same effect by editing ChangeList browseRecent: 2000 so that the number 2000 becomes something else, using trial and error.)

One you have a recent changes browser, showing, say, changes back as far as your last snapshot, you will have a list of everything that you have done to Squeak during that time. You can delete items from this list using the yellow-button menu. When you are satisfied, you can file in what is left. It's a good idea to start a new change set, using the ordinary change set browser, before you do the file in, so that all of your recovered code will be in a new change set. You can them file out this change set.

One useful thing to do in the Recent changes browser is to remove doIts. Usually, you won't want to file in (and thus re-execute) doIts. But there is an exception. Creating a class shows up as a doIt. Before you can file in the methods for a class, the class must exist. So, if you have created any new classes, first file in the class creation doIts, then remove doIts and file in the methods.

When I am done, I like to file out my new ChangeSet, quit Squeak without saving the image, restart, and make sure that my new ChangeSet files back in cleanly.