View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Lab1 - Summer 2000

This lab serves as an introduction to Squeak.

Step one:

Move your mouse to the light green area, click the right button and select "open... workspace". Open a Transcript window the same way. Try to move the windows around by clicking on the top bar of the window and dragging it around. Also try to resize the windows by moving your mouse to the window borders. Now, go to the workplace window and type

Transcript show: 'I know how to print! My life is so much better now'.

After that right click on this text and select DO IT. This text should appear in the transcript window.

Now, let's do something more fun. Squeak has it's own built-in WWW browser, Scamper. Let's play with it. Go to the Workspace window and type

Scamper openAsMorph.

Select the text you just typed and do it. You will see the initial Scamper window open and see that the default first page it opens is, the Squeak information page.

The second pane from the top contains the URL of the currently loaded page - you can type into this pane to open any page you like. Try it! If you right-click over the page, you'll get a menu that offers choices similar to the right-button menu in Netscape Navigator. Experiment with the "view source" and other choices. Also, look at the Transcript window after you load a page and you will see Scamper's output while it loads. When you're done experimenting with Scamper, close its window by clicking in the open square on the titlebar.


Step two:

Open a System browser: it has 4 small panes on the top and one large pane on the bottom. The top panes from left to right are Class categories, Classes, method categories, and Methods. Let's create our own Class category: right click on the first pane and choose ADD ITEM. Give it a name, say My-Classes. For this category we will create a class Lab1. Notice that the bottom pane shows you the template code for a new class. Replace the NameOfClass with Lab1 and remove "instVarName1 instVarName2" and "ClassVarName1 ClassVarName2" from between the two sets of quotes. To delete use backspace button, rather than delete. When you are done, right click on the mouse and choose accept from the menu. Now you have defined a class. In the Method Categories pane choose New Category: testing. Again the template code appeared in the bottom pane. Replace it with the following code.

hello: doTimes say: message

(doTimes > 15)

ifTrue: [ Transcript show: 'I will get you!']

ifFalse: [1 to: doTimes do: [:i | (Transcript show: message) cr]]


Go to the workspace window and type:

Lab1 new hello: 2 say: 'I am alive!'.

So, what does this function do? To answer this question you should try running this method several times with different inputs (or merely inspect the code).


Step Three:

We will now learn how to import files. Select your Class Category (in my case it's My-Classes).

Right click on it and select File Out. This will save this file to the Squeak's local directory.

Go to your System Browser and remove this category. (This removes it from the current squeak environment, but your code should still be on disk on the file you just "filed out".) To import it back you need to right click on the Squeak's green background and select open file list. A window divided into three panes pops up. Select your file in the top right pane and file it in. Check your system browser to make sure that your class was imported back into the environment.

Now open this file by right clicking on the green background and selecting "open... file" (not "open... file list"). Your file now appears in a window as a text file. You should see the smalltalk code you wrote for class Lab1 in this file. You can edit the file my making changes in this window (effectively the window is a text editor).

Below your code, write a short explanation of what the hello:say: method does (what you figured out from step two).

To save changes to this text file you are editting, do an "accept".


Step four:

Suppose you wanted to write an interactive program. To do that you would need to prompt user for input and read input from the user with the help of window. An example of such a window is displayed when you click on the middle of minimized "Play With Me - 8" window (or any minimized window). A window should pop up that says "Edit the label, then type RETURN". These little windows to get user input occur in many places in Squeak. You need to find the method that pops up a dialog box to ask the user a question and read response.

When you find this method being called somewhere, copy the entire method to the file you were editting in step 3. (Don't forget to save changes to the file.) If you are used to using shortcuts Alt in Squeak works as Ctrl in windows.

Hint: This pop-up window is similar to the window you'll see when you select "add new file" from the File List browser. The file List browser is an instance of class FileList. There are several other places you can find this type of window - go hunting!



You will turn in the file that you have been editting. By the end of the lab, that file should have

Turnin using the Summer 2000 Turnin Information by 6pm on Wednesday. The project name is "l1" (lab1).

Questions for Lab1 - Summer 2000

Link to this Page