Revised 1999 09 07
Introduction to the Macintosh and MPW
(CMPT 145 students can surely skip this.)
operating system of the Macintosh computer.
filefolderdialog box
pointclick, double clickselect
dragopenclose
pull down menucutcopy
paste
Part IB
2) You are now ready to run MPW.
• Insert your own ZIPdisk into the ZIPdrive.
• If your disk has been previously used in a Macintosh
computer, it will
"mount" and appear with its name on the desktop. If it is
blank, you
will get a dialog box notifying you that your disk cannot be
read and
asking if you want to have it initialized. Select the type of
format you
want (Mac OS Standard, Mac OS Extended, or DOS) and name
the
disk. Note: If you want to transfer files between the MACs and
PCs,
format the ZIP disk to DOS. For our
purposes, the disk name
should have no spaces in it.
It may not have any periods,
slashes, apostrophes, colons, or quotes, either.(Apart from colons,
this is an MPW limitation, not a Mac limitation.) If the disk
has a name
already with any of these in the name, please rename it now.
Call it
some such name as "DodieDeeDanielsDisk" or something to that
effect.
To do this from the finder, click on the name of the file
under its icon
and wait a few seconds for the editing I-beam cursor to
appear. Type a
new name to replace the old one. NOTE:
The Mac will read PC disks,
but you mightnot be able to use your
disk with MPW. If not, copy your
files to a Mac disk. Alternately, store your files in a
directory other
than the ROOT directory, and you should be OK. To do this,
create a
folder on your PC disk using the finder. Call it, say
"MPWFiles" or some
such thing—no special characters in name.
• NOTE:All disks fail
eventually. For this reason, you should have
another disk
to back up your files.
• You need not create any other folders on the disk at
the present time,
but you should leave it in the drive for storing your
files.
• Now, open the hard disk, if it is not already, by
double clicking on its
icon at the top right.
• Open (run) the application MPW Shell in this folder in
the same way (by
double clicking on its icon). Or select from the menu
Apple:Favourites:MPW Shell. After a while, you will be facing
a screen
with a file called "Worksheet" now open and having some pull
down
menus at the top.
• Whenever you start MPW, or switch disks, you will have
to set the
directory to where your files reside. From the Directorymenu you
must select Set Directoryand from the resulting
box, click on
"desktop", then on the name of your disk (then your folder, if
you made
one, and you must if using DOS formatted), finally on "select
current
directory."
default directory by choosing the showcommand under the Directory
menu. It will be here (in the default directory) that
the files you create
will be stored.
do this,
• open a new window by choosing Newfrom the Filemenu. You will get a
blank window overlaid on top of the worksheet. For ease of
switching
between the two, you may wish to select Stack Windowsfrom the
Windowmenu, or change their
size using the grow box (bottom right of
window) and/or their or position on the screen by dragging
them by
their title bars.
• In the
window you have opened, type out your first program.
• Be sure that you include all the required elements of
a correct Module
as outlined in the lecture. Try the "hello world" example in
Chapter 2 of
the on-line text (or lecture) as your first assignment. Use
some
imagination in the message.
• To correct errors just as they are typed, backspace
and retype.
• To indent, use the tab key. Subsequent lines will
indent the same
amount. You can backspace over a tab to reduce the indentation
level.
• When you think you are done, choose Save Asfrom the Filemenu. You
will see your own directory and can type a file name now. The
Modula-
2 compiler expects that THE FILE NAME IS THE SAME AS THE
NAME
OF THE PROGRAM MODULE, PLUS THE EXTENSION ".MOD" so use
this name. (e.g. if the program is called "Hello," then the
file containing
it should be called "Hello.MOD") Note, however, that although
Module
names and the .MOD extension are case sensitive, file names
in
general are not. That is, don't have two programs called
"ThisProg" and
"thisprog." Modula-2 can distinguish these, but the Macintosh
OS
cannot distinguish between them as filenames.
• Should you make later changes to this file, perhaps
after re-opening it
following a rest of a few days, the changes can be saved with
the Save
command in the Filemenu whenever the file
to be saved is in the
topmost (active) window. This will save to the name on the
title bar.
• You may wish to list the files on your disk just to
make sure. Do this by
selecting the List Directoryoption from the Filemenu. The list will
appear on the active window, so you may wish to have the
Worksheet
on top when you do this. If you don't want to keep this list,
delete it
immediately by selecting the "Undo" command from the Editmenu.
This may be useful for other things too. Note that if you
Undo
somethingand change your mind, the next Undowill put it back. Note
also that there is a keyboard equivalent for this and other
commands
listed on the menu. Once you memorize some of these
equivalents, feel
free to use them by pressing the "command" button along with
the
appropriate letter key. (Do this by pressing and holding the
command
button, then while it is down, pressing the letter key for the
command
you want executed.)
4) You are now ready to compile and link your
program. To do this,
• Pull down the M2menu and choose Compilefrom the top group,
that is
to act on the active (target) window.
• The worksheet window will come to the
front to report any errors. Your
window is still the target.
• If the cursor first changes to the
spinning beachball, and when done,
reports nothing, all went well and you can go to the next
step, and the
next menu item. Chances are, however, that there will be error
messages,
like the following printed on the worksheet.
# 6 BEGIN
##### ^ 23: ';' expected
File "TWTransfer:Hello.MOD"; Line 6
Modula2 - Execution terminated!
commentary about what the error is suspectedto have been. This one
was generated by trying to compile a Module called Helloin which
there was a line with a missing semicolon. Deal with errors as
follows:
- triple click on the line "File ... line ..." and press the
"Enter" key (not
Return)
- your file will re-open with the offending line selected. The
error
should be on this line, but may be on a previous line. Correct
the
error with appropriate editing.
- bring the worksheet back to the top and triple click on the
next error
message
- repeat until all errors are fixed (you think)
- now go back to the worksheet window and delete all the
error
messages, and
try again to compile as before. You may go through
this process several times, as each time the compiler will
attempt to
compile more code before giving up. Correcting errors
sometimes
introduces new ones, or reveals old ones that the compiler
could not
pick up the first time.
• Once the compile finished
successfully (no new error messages) you
could list your directory again, just to see the effect. There
will be a
new file called (using the example above) Hello.MOD.o or
Hello.MOD.x
where the ".o" or ".x" signifies the "object code" generated
by the
compiler.
• Now, you are ready to select the next
item in the M2menu (called
Make Link File)
which causes the generation of a Makefilethat the
linker requires to patch your code together with the
preexisting library
modules (for things like STextIO).
Do it.
• This creates yet another file on your
disk, called Hello.make. During the
course of this, the name Hello.MODwill be printed on the Worksheet.
• Now select the third item from the
same M2menu (called Re-Link).
This uses the compiled code and the makefile to create the
final
application. When it is done (it may take a few seconds) the
linker will
"beep" twice to let you know.
• This creates yet another file on your
disk, simply called Hello. The
others are all text files that could be opened and edited.
This one is
not; it is a program, and can be executed.
• Assuming that all has gone well to
this point, you may now execute
your application.
- Type its name in the worksheet window and press the "Enter"
key
(not "return"). (But hold on.. if you just did a successful
re-link, the
name was typed for you, so just press "Enter" -- you do not
have to
pay for this courtesy; I provided it free.)
- MPW switches control to your program and runs it. A text
window
will open and your application will then run, with the output
being
typed in a window entitled terminal.
- Alternately, you may run your program switch to the Finder
and
double click on your application Hellofor the same effect.