\chapter{Overview of the Bobcat Scheme system}
\label{overview}

The HP 300 (Bobcat) computer uses a Motorola 68020 microprocessor.  As
configured in the 6.003 lab, each Bobcat has approximately 7 megabytes
of physical memory, two 55-megabyte hard disks, and two
3$\frac{1}{2}$-inch floppy disk drives.  The computers are networked
to provide access from each machine to a laser printer. Student
program files are stored on personal floppy disks.

The Bobcat computer runs the Unix timesharing system, but 6.003 Scheme
uses a protected subsystem that always runs the Emacs editor and
Scheme.  If you are familiar with Unix and would like to play around
in the Unix shell, ask a lab TA for assistance.

\noindent
Here is the general procedure for using Scheme on a Bobcat: 

\begin{itemize}
\item Log in to Unix as {\tt u6003}.  No password is required.
If you have a floppy disk, insert it into the left-hand drive.  The
system will copy all the files from your floppy disk onto the Bobcat
hard disk so that they can be rapidly accessed.  Then the system will
load Scheme and start the Emacs editor.  You can use the editor to
type, modify, and evaluate Scheme expressions, and to load and save
files.  In general, all interaction with the Scheme system is via the
editor.\footnote{This is unlike the 6.001 system, in which you are
sometimes typing at the editor and sometimes typing directly at the
Scheme read-eval-print loop.  We hope that the 6.003 system will be
easier to use.}
\index{buffer}

\item The editor can deal with a number of separate chunks of text
called {\em buffers}.  Initially, when you load Scheme, you will be
typing at a buffer called {\tt *scheme*}.  Whenever you evaluate a
Scheme expression, the result will be inserted at the cursor position
in {\tt *scheme*} buffer.  (See section~\ref{running-scheme}.)

\item Normally, you will read in a file, or create a new file, that
holds the programs you are developing.  Thus, you will normally be
using two buffers---the {\tt *scheme*} buffer for holding interactions
with Scheme, and another buffer for holding your program text.  You
can evaluate a Scheme expression that appears in either buffer, but the
result of any evaluation will always appear in the {\tt *scheme*}
buffer.  Thus, in developing a program, you would normally type the
definition into the file buffer and evaluate this definition by
typing \esc{z}. (See section~\ref{evaluating expressions}.)  Then you
would switch to the {\tt *scheme*} buffer to test your program.

\item  You can view more than one buffer at once by directing the
editor to divide the screen into separate areas called {\em windows}.
You can reserve a window on the screen for displaying graphics.  By
using one, two, or three windows, you can choose to view the
{\tt *scheme*} buffer, some other buffer, your graphics, or any
combination of these.

\item When you are satisfied with a program, you can save the buffer
containing it as a file on the Bobcat's local hard disk.  It is a good
idea to save your programs from time to time as you make changes.

\item When you are done, log out.  Any files you created on the hard
disk will be copied to your floppy disk, which you should remove from
the drive and take with you.  {\bf Do not remove your floppy disk from the
drive until after you log out.}  Otherwise, your new files will not be
copied to the floppy disk.

\end{itemize}

\section{Screen indicators of the system's status}

When using the Bobcat for 6.003, you are almost always interacting by
typing at the editor.  When the editor is running, the screen will be
divided into regions called {\em windows}.\index{windows}  At the
bottom of each window there will appear a {\em mode line}, displayed
in reverse video.  Information in the mode line tells you the status
of Scheme and of Emacs.
For example, the mode line \index{mode line}


\begin{scheme}
-----Emacs: laplace  I 1 \verb|[|REP Loop\verb|]| (Scheme)57\verb|%|-----
\end{scheme}
\noindent
identifies that the name of the buffer is {\tt laplace}, that Emacs is
currently configured in Scheme mode, and that the part of the
buffer being examined is 57$\%$\ of the way through the whole buffer.
Saying that Emacs is running in Scheme mode means that, in addition to
the ordinary Emacs text-manipulation commands, there are also special
commands to aid you in running Scheme.  The {\tt I} means that Scheme
is waiting for input (as opposed to running).  The {\tt 1} and {\tt
REP Loop} mean that Scheme is at level 1 running its read-eval-print
loop. Section~\ref{running-scheme} tell how to interpret these
indicators of Scheme's status.

A mode line that contains two stars at the left, such as
\begin{scheme}
-**--Emacs: laplace  I 1 \verb|[|REP Loop\verb|]| (Scheme)57\verb|%|-----
\end{scheme}
\noindent
indicates that the buffer has been modified since the last time it was
saved on the disk.

Certain buffers used by the system, such as buffers used for
displaying graphics and disk directories, are {\em read-only}.
This is indicated by two percent signs at the left of the mode line.
For example, the mode line
\begin{scheme}
-\verb|%%|--Emacs: graphics I 1 \verb|[|REP Loop\verb|]| (Scheme)57\verb|%|---
\end{scheme}
\noindent
indicates that the {\tt graphics} buffer is read-only---Emacs
will not let you modify it.

Most of the time when you are interacting with Scheme, you will be
typing in a special buffer called {\tt *scheme*}.  This is the buffer
in which the Scheme interpreter prints the results of evaluating
expressions.

At the very bottom of the screen, below the mode line for the lowest
window, is a one-line area called the {\it echo area}.\mainindex{echo
area} Often, the system will display messages in this area and ask
you to repond.  When you type your reply, it will also appear in the
echo area.  The echo area is also used for typing Emacs {\it extended
commands}.\index{extended commands} To invoke an extended command,
type \esc{x} followed by the command name and press {\sc return}.
Your typing will appear in the echo area.

\section{Entering and leaving the system}
\label{login}

The Bobcats are normally left running at all times.  When you are
through using a machine you should log out, using the
Emacs extended command \esc{X logout}.

When a Bobcat is not in use (when it is first turned on, or after
someone logs out) it will be running a {\em login loop}; and a message
asking you to log in will appear near the top of the screen.  Type
{\tt u6003} and press {\sc return}.  This will start the Emacs editor
and load the 6.003 Scheme system, which takes about a minute.  Next,
the system will ask you if you want to use a floppy disk.  If you have
a disk, insert it into the left-hand of the two disk drives at the top
of the Bobcat.  Be sure that the disk label is face up and toward you.
The system will check that the name on the disk matches your user name
and warn you if the two names do not match.  If the floppy disk is
being used for the first time, the system will offer to initialize the
disk.


The login procedure copies the files from your floppy disk onto the
Bobcat hard disk so they can be easily accessed.  When you are
finished using the Bobcat, you should be sure to log out.  Give the
Emacs command
\esc{X logout}.\mainschindex{logout}  Emacs will check whether all
editing buffers have been saved on the hard disk since the last time
they were modified, and ask you if you want to save any buffers that
need to need to be saved.

If you are sure a Bobcat is not being used, but it is not running the
login loop, you should logout and login anew before using the system,
because there is no way to know which variables have been defined or
redefined in the environment.

\section{Files and floppy disks}

Your 6.003 package of notes should have included a 3$\frac{1}{2}$-inch
floppy disk that you can use for saving individual files from one
computer session to the next.  When you log in, the files on your
floppy disk are copied to a directory on the Bobcat hard disk.  When
you log out, this directory is copied back to your floppy disk, and
the previous contents of the floppy disk are destroyed.

\subsection{Disks and Files}

Information in Unix is organized in terms of {\it files}, which are in
turn grouped into {\it directories}.  A file is a bunch of information
that is stored together, and has associated with it a file name that
must be unique on the directory.  In general, a file is specified by a
Unix \defining{path name}, which is a sequence of directory names
separated by slashes, ending in a file name.

For example, the path name {\tt /u/6003/files/ps1.scm} specifies that
the file named {\tt ps1.scm} in the directory named {\tt files}, which
is itself a subdirectory of the directory named {\tt 6003}, which is a
subdirectory of {\tt u}, which is a top-level Unix directory.  When
you log in, the system will copy the files from your floppy disk onto
the directory {\tt /u/6003/files}.  When you log out, the
files on this directory will be copied to your floppy disk.

In principle, you would need to specify the entire sequence of
directory names in order to indicate a file.  However, the system sets
up a {\em default prefix} consisting of {\tt /u/6003/files}.  Whenever
Emacs asks for a file name, it will print {\tt \char"7E/files/}, which
stands for the default prefix, onto which you append your file name.
Thus, to access the file {\tt /u/6003/files/ps1.scm} you need
only type {\tt ps1.scm} after the {\tt \char"7E/files/} printed by Emacs.

To access a file on some other directory, rub out the prefix and type
any path name you choose.  If you are a Unix hacker, you can explore
to see how more general directory names are structured, but for 6.003
you need only (should only) work in the default directory.

\subsection{Non-standard use of floppy disks}
\label{backup} \index{backing up disks}

Files are automatically copied from and to your floppy disk when you
log in and log out.  The system also includes a few commands that give
you additional control over floppy disks.  You do not normally need to
use these, but they may come in handy for making backups or for other
purposes.

\begin{itemize}
\item The Emacs command
\escx{save-floppy} will save the contents of the 
{\tt /u/6003/files} directory onto the floppy disk you
specify.  (Emacs will ask you which floppy disk you want to use---the
one in the left or right drive.)  This operation is automatically done
when you log out, but you would use this command explicitly in order
to make a backup copy.\mainschindex{save-floppy}
People make mistakes, especially at 3:00 AM while doing a homework
assignment.  For that matter, computers do too, occasionally
scrambling a formerly fine file system.  For this reason it is
generally a good idea to periodically backup your files onto another
disk.  If you work regularly with a partner, you can use one of your
floppy disks for backup.

% \item The command \escx{load-floppy} will replace the contents of the {\tt
% /u/6003/files} directory by the files on the specified
% floppy disk.  This operation is automatically done when you log
% in.\mainschindex{load-floppy}

\item The command \escx{examine-floppy} will show the names of files stored
on a given floppy disk.  Files are stored on the disk in nonstandard
format, so you must {\tt load} the disk into the {\tt files}
directory before you can actually use the files.
\end{itemize}

When someone logs out, or reloads the {\tt files} directory from a
floppy disk, the previous contents of the directory are temporarily
saved.  The directories {\tt /u/6003/files-1} through {\tt
files-3} contain the three previous versions of the {\tt files}
directory.  In case of some disaster (such as accidentally destroying
the {\tt files} directory by loading from a new disk) you may be able
to recover by looking in these other directories.  You should
probably, however, ask a TA for help.

\subsection{Initializing Disks}
\index{initializing disks}

If the floppy disk has a format that is unrecognizable by the computer
(for instance, if this is a disk that has never been used) the system
will offer to initialize the disk for you.  If you indicate that you
want the disk to be initialized, the system will ask you to provide a
name by which to identify the disk.  The name is for your own use---to
keep you from getting confused if you are using more than one disk.
The case of the letters in the disk name is significant.  Once
initialization has begun, do not touch anything until the procedure
has finished.

If a disk is already initialized and you want to re-initialize it for
some reason, place the disk in one of the disk drives and execute the
Emacs command \esc{X
initialize-floppy}.\mainschindex{initialize-floppy} you log in
(section~\ref{login}.)  Remember: initializing a disk will destroy any
information previously on the disk.

\section{Hardcopy listings and screen images}
\index{hardcopy} \index{printer}

There are two laser printers in the 6.003 lab.  You can print a text
file on by using the Emacs command \escx{print-file} followed by the
file name.\mainschindex{print-file} The Emacs command
\escx{print-screen} will make the laser printer produce an image of
everything on the screen, so you can get hardcopy of graphs and other
graphics.
\mainschindex{print-screen}

Do not use \escx{print-screen} for printing text files.  Instead, use
the command \escx{print-buffer}.  This is much faster than \esc{X
print-screen}, since it transmits character codes rather than screen
bit images, not to mention that it prints the entire buffer-not only
the part that appears on the screen at the moment.
\mainschindex{print-buffer}
