\documentstyle[a4,12pt]{article}
\begin{document}
\author{APM Manual pages}
\title{IMP Events}
\maketitle
\parskip .1 in
\setcounter{secnumdepth}{10}
\parindent 0in
\section{Preamble}
Synchronous Events in Imp 2.0 et seq as proposed April 1984

\section{How to signal and trap them}
Events may be signalled by the system or by the user (using \%SIGNAL in IMP) and
trapped in am IMP program by the \%ON \%EVENT.. construction.

\%on \%event $<$eventno$>$, $<$eventno$>$, ..... \hspace{0.3 in} \%start
\\ \hspace*{0.2 in} ...
\%finish

"\%event" \hspace{0.2 in} is optional in the statement above.

Once the event has been trapped, further information may be obtained by
interrogating the built-in record EVENT..

\%recordformat eventfm(\%byte event,sub,\%short line,\%integer extra,
\\ \hspace*{1.5 in} \%string(255)message,\%integerarray r(0:15))

where sub and extra have the meanings defined in a later section.

\section{Caveats}
In general, reliance should not be placed on the detailed distinctions made by
the EVENT\_SUB field: the EVENT\_MESSAGE field provides a textual
explanation for the occurrence of the event.

The differences between the new scheme and the old one are..

There are some changes in the detailed meaning of some sub-events.
Event 9 is now reserved strictly for End-of-Input.
Filestore failures are handled by Event 3.
Events 3 and 4 switch meanings.

The reversal of the significance of events 3 and 4 compared with EMAS IMP
was unintended in IMP - 77. The re-reversal shown above corrects this in
the interests of goodwill.

\section{Event Numbering}
The event numbering is presented below as follows:
The event NUMBER is specified in the title of each page.
Each page contains a list of SUB-event numbers, and, where relevant,
explains the meaning of the EXTRA field.

\subsection{Event 0: Program Termination}
\small\tt \begin{verbatim}0    -       normal termination (%stop)
1    -       forced termination (^Y)
2    a       Bus Error:
             Attempt to access an operand at non-existant location a.
3    a       Address Error:
             Attempt to access a non-byte operand at odd address a.
4    -       Illegal Instruction        \/  Usually a result of the
5    -       Reserved Exception or Trap /\  program being corrupted
8    -       Using a privileged instruction while in user mode.
\end{verbatim}\rm  \normalsize 
\subsection{Event 1: Overflow}
\small\tt \begin{verbatim}1    -       integer overflow
2    -       real overflow
3    -       string overflow (more than 255 characters)
4    -       division by zero
\end{verbatim}\rm  \normalsize 
\subsection{Event 2: Resource exceeded}
\small\tt \begin{verbatim}1    -       store space exhausted
2    -       output limit exceeded
3    -       time limit exceeded
\end{verbatim}\rm  \normalsize 
\subsection{Event 3: Input/Output Error}
\small\tt \begin{verbatim}1    -       data transmission error
2    -       timeout
3   code     failure to open file
4   code     failure on other file system operation
\end{verbatim}\rm  \normalsize 
\subsection{Event 4: Input Data Type Error}
\small\tt \begin{verbatim}1   char     non - numeric char for numeric input
\end{verbatim}\rm  \normalsize 
\subsection{Event 5: Invalid arguments}
\small\tt \begin{verbatim}1    -       invalid values for %for loop
2   culprit  illegal exponent for exponentiation
3    -       upper bound less than lower in array declaration
\end{verbatim}\rm  \normalsize 
\subsection{Event 6: Range error}
\small\tt \begin{verbatim}1   value    value outside range of destination/result
2   index    array index out of bounds
3   index    switch index out of bounds (if distinguished from 2)
\end{verbatim}\rm  \normalsize 
\subsection{Event 7: String resolution failure}
No additional information supplied.

\subsection{Event 8: Undefined Value}
\small\tt \begin{verbatim}1    -       unassigned variable (value or pointer)
2   index    switch to undefined label
3    -       %for loop variable corrupt
\end{verbatim}\rm  \normalsize 
\subsection{Event 9: End of Input}
This event is no longer signalled for miscellaneous I/O errors such as
"invalid stream number or "file not found", but is reserved exclusively
for attempting to read past the end of a file.
No additional information supplied.

\subsection{Event 10: Library Procedure error}
This is generated by certain utility libraries, such as Edwin.
The SUB and EXTRA meanings are defined in the documentation relating
to the libraries concerned.

\subsection{Events 11 to 15}
These numbers are not used by system components or standard libraries,
and are intended for general purpose use by the programmer.


\vspace{.75in} view:events printed on 16/02/89 at 16.49

\newpage
\tableofcontents
\end{document}
