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.
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.
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 |
|
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.
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.
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.
Each window has a title bar with a "close" icon (an
x) in the upper left and a
"collapse" icon
in the upper right.
FillInTheBlank
.) Experiment with
full screen, and with changing the stacking order. Select
window color; the system is now waiting for you to select a
color for the window. Position the mouse anywhere on the screen
and click it to select a color.ifTrue:
. To type these capitalized shortcuts you
can hold down shift and the shortcut key while you type
t, or, more conveniently, you can hold down ctrl
while you type t.
Key |
Description |
Notes |
z |
Undo |
|
x |
Cut |
|
c |
Copy |
|
v |
Paste |
|
a |
Select all |
|
D |
Duplicate. Paste the current selection over the prior selection, if it is non-overlapping. |
1 |
e |
Exchange. Exchange the contents of current selection with the contents of the prior selection |
1 |
y |
Swap. If there is no selection, swap the characters on either side of the insertion cursor, and advance the cursor. If the selection has 2 characters, swap them, and advance the cursor. |
|
w |
Delete preceding word |
|
2+3
in the
workspace, select it and then select the print it menu
option, or type command-p. (Print it and do
it work on the selected text, but if there is no selection,
they work on the whole of the current line.) Both commands
evaluate the selected expression. The print it command
displays the result, but the do it option doesn't display
the returned value. The short-cut key for do it is
command-d. These are very common actions, so practice the
shortcut keys.
Key |
Description |
d |
Do "it" (where "it" is a Squeak expression) |
i |
Inspect "it": evaluate "it" and open an inspector on the result. ("it" is a Squeak expression). Exception: in a method list pane, i opens an inheritance browser. |
p |
Print "it". Evaluate "it" and insert the results immediately after "it." (where "it" is a Smalltalk expression) |
I |
Open the Object Explorer on "it" (where "it" is an expression) |
Key |
Description |
f |
Find. Set the search string from a string entered in a dialog. Then, advance the cursor to the next occurrence of the search string. |
g |
Find again. Advance the cursor to the next occurrence of the search string. |
h |
Set Search String from the selection. |
j |
Replace the next occurrence of the search string with the last replacement made |
A |
Advance argument. Advance the cursor to the next keyword argument, or to the end of string if no keyword arguments remain. |
J |
Replace all occurrences of the search string with the last replacement made |
S |
Replace all occurrences of the search string with the present change text |
Key |
Description |
l |
Cancel (also "revert"). Cancel all edits made since the pane was opened or since the last save |
s |
Accept (also "save"). Save the changes made in the current pane. |
o |
Spawn. Open a new window containing the present contents of this pane, and then reset this window to its last saved state (that is, cancel the present window). |
Spline example
, select it
and do it. Use the red button to click off several points
on the screen. Then click another button: you should see a curve.
What does restore display do to the curve? Can the curve
lie inside a window? What do scroll bars do to the curve?
Why?Spline example1
, then select do
it. This is a typo and you should see a window pop up. Push
the Abandon button. (example1
is a valid
message, just not for Splines.)Spline exampl
then do it. This is
also a typo, but this time Squeak suggests some possible
corrections. Select cancel or example. (Here
exampl
is not a valid message on any object, so the
system looks for messages with similar spellings.)Forms are rectangular blocks of pixels, like mini-bitmaps.
f := Form fromUser
. Then select a rectangle from the screen. (There are two ways to type the assignment operator. You may either type colon-equal (like Pascal) or you may use the left arrow, which is really the ASCII underscore (_) character. In other words, type the _ key and see <- on the display. Select a rectangle on the screen. (This expression created a new form and assigns it to variable f.)
f
Form fromUser
(Same statement, just use the left-arrow this time.)
f displayAt: 100 @ 100
. Use restore display from the world menu if necessary.
100@100
specify
Points
; the @ character is a binary infix operator.
For example 20@500 means the point with x=20 and y=500.f
Form extent: 30@40
to create a blank form. The
extent:
message creates a form that is 30 pixels wide
(x) and 40 pixels high (y).f displayAt: Sensor waitButton
. Click the
mouse button.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).
even
method in class Integer. How does
this method determine its result?
______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________
Type and execute with the following 5 lines:
circleFormForm extent: 25 @ 25. aCircle
Circle new. aCircle radius: 12. aCircle center: 12 @ 12. aCircle displayOn: circleForm.
Describe what you think this code does. (Hint: you won't see any effects directly.)
______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________
Type in and evaluate some expressions to verify this code does what you say it does.
Do you have any comments about this script? For future reference, were any instructions unclear/frustrating (which ones)?
______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________