\chapter{Macaulay under MPW}
\label{ap-mpw}

        Installation of Macaulay on a Macintosh with a hard disk: Drag
the folder "Macaulay" to any convenient location on the hard disk.
(The entire contents of the folder, arcane though some may seem, are
necessary.)  Now you are ready to run Macaulay.

        Macaulay was originally designed to run under UNIX.  In the
Macintosh environment MPW provides the services that would be
provided by the Unix operating system, and then some! (MPW =
Macintosh Programmer's Workshop.  The version here provided is
licensed from Apple for distribution with Macaulay, courtesy of the
Mathematical Sciences Institute at Cornell University.)  Thus to run
Macaulay you must begin by launching the application MPW, which is
inside the Macaulay folder.

        When you have launched MPW, you will see a window labeled
"Worksheet", and you will be talking to the MPW interpreter, which
acts something like the finder.  One peculiarity of MPW which is very
important for using Macaulay is that it interprets \return\ 
(produced by pressing the return key) differently from {\tt <enter>}
(produced either by pressing the enter key or by holding down the
command key while pressing the return key.)  If you are new to MPW,
try the following exercise to understand the difference:
\begin{itemize}

\item Type the word "Directory" (without the quotation marks.  You can
capitalize or not, since capitals don't matter to MPW).  Press
\return.  What happens?  (Answer:  Nothing.  MPW acts as an editor,
and you have simply moved to the next line, presumably to add more
text.)

\item  Place the cursor anywhere on the line with the word "Directory"
and press {\tt <enter>}.  What happens?  (Answer:  MPW interprets the
word "Directory" as a command, and executes it, producing the full
name of the "current folder" -- that is, the folder whose contents is
listed when you select "open" from the file menu.)

\item  Select the word "Directory" using the mouse.  Now press {\tt <enter>}.
What happens?  (Answer:  Again, MPW executes the selected word as
a command.  This would also work if you selected many commands
together, perhaps on many lines.)

\item  Again select the word "Directory".  Now press \return.  What
happens?  (Answer:  The selected word simply disappears, and is
replaced by a blank line!  This replacement of selected  text is the
standard response of a Macintosh editor.

\end{itemize}

        Don't forget that you can use either command-\return\ or
{\tt <enter>} (but not command-{\tt <enter>}!)  interchangeably.

\section{Controlling Macaulay from a window}

        One of the great virtues of the MPW system is that you can
type commands to Macaulay in one window, which becomes a log of
the session from which any part of it can be reproduced, and have
Macaulay type its responses in another window, such as the
worksheet.  Each window corresponds to a file which can be saved on
the disk.  This is the normal way of using Macaulay under MPW, and
we will now describe it.

        For convenience, start by setting the "current directory" to be
the Work folder inside the Macaulay folder.  Do this by going to the
"Directory menu" inside MPW and selecting the directory whose name
ends with the word "Work".

        Now open a new window by selecting "new" from the file menu,
naming the new window whatever you like when the dialogue box
comes up.  Then choose "tile windows" from the Window menu to
make both of the two windows conveniently visible.  Try clicking
inside each of the two windows in turn, to see that they become
active when you click inside them.  While the Worksheet window is
active, try pressing command-a to select everything, and then press
the delete key, to clear that window of the remains of the previous
experiment.

        To start Macaulay in the Worksheet:  Click in the Worksheet to
make it active.  Then type the word "Macaulay" (no quotation marks)
and press {\tt <enter>} (or, as usual, command-\return.)  Macaulay will
start up in the Worksheet.

        Now click on the other window.  You are ready to type a
command to Macaulay.  Try for example typing "help", followed by
{\tt <enter>},  to see some of the features that Macaulay has.  (Don't
forget that Macaulay does not react to a command unless you type
{\tt <enter>}.  In particular, if you type \return\ after a command instead
by mistake, nothing will happen!).

\section{Customizing the MPW environment}

        Many aspects of the MPW environment are controlled by the
document called "UserStartup", which is in the Macaulay folder.  The
adventurous user may wish to experiment with modifications of this
file.  In particular the "environment variable" MacaulayPath controls
which folders are searched to find commands and scripts for
Macaulay, and the "DirectoryMenu" command controls which folders
are listed under the directory menu.

         For example, if you create a new work folder named "Fun"
inside the "Macaulay" folder for some particular project, you might
want to add its name to the list of names in these lines of the
UserStartup file.  Thus you might change the lines

\begin{verbatim}
        DirectoryMenu "{mpw}" "{mpw}Scripts" "{mpw}Work"

        Set MacaulayPath ":,{mpw}Scripts:"
\end{verbatim}

to

\begin{verbatim}
        DirectoryMenu "{mpw}" "{mpw}Scripts" ^
        "{mpw}Work"  "{mpw}Fun"

        Set MacaulayPath ":,{mpw}Scripts:,{mpw}Fun:"
\end{verbatim}

        Note that the useful abbreviation {mpw} stands here for the
full name of whatever folder contains the MPW application -- in our
case the Macaulay folder.  Also, the character which is made by
pressing option-d, tells MPW to ignore the carriage return
immediately following it, so that the files listed above after
DirectoryMenu appear to MPW to be on a single line.

        Neither of these changes is actually necessary.  The change in
the first line simply adds the convenience of being able to switch
directories to the "Fun" folder instantly from the Directory menu.
(Else you can switch to it using the "set directory" command from
the Directory menu.)  The second change enables Macaulay to find
scripts that you store inside the Fun folder even when this folder is
not the current folder.  (When the Fun folder is the current folder,
Macaulay can find them because of the initial item ":" in the
MacaulayPath.)



\section{Some Peculiarities of Macaulay under MPW}
\begin{itemize}

\item  While Macaulay is active,  files cannot be saved in the
normal way.  Instead, one must save a file (corresponding to the
contents of a window) by closing that window -- just click in the
close box at the upper right hand corner.  Then select "Open" from the
file menu and reopen the window to go back to work.  It is
sometimes important to do this, because if Macaulay crashes the
contents of windows that have been put there since the last save
will be lost.  (Note that the Worksheet cannot be closed, and thus it
cannot be saved while Macaulay is running.)  An option is of course
to quit Macaulay (type exit or command-.), save the file in the usual
way, and then restart Macaulay in the Worksheet and get back to
where you were by selecting all of the window you are working from
and typing {\tt <enter>}.

\item  Output from Macaulay will appear wherever the cursor is in
the Worksheet.  Thus to be sure that output appears at the end of the
Worksheet, after moving the cursor by clicking elsewhere within the
Worksheet, it is necessary to click at the end of the Worksheet.

\end{itemize}
