assign-procedure = assign-output | assign-input | assign-error .
assign-output = ASSIGN "(" OUTPUT "," output-procedure ")" .
assign-input = ASSIGN "(" INPUT "," input-function ")" .
assign-error = ASSIGN "(" ERROR "," error-procedure ")" .
This is the way a user-defined console character I/O routine may be assigned to the standard console READ, READLN, WRITE and WRITELN built-in procedures, or to assign an output procedure to the ERROR message output..
<output-procedure>::
May be any procedure name that is defined with one and only one BYTE or CHAR argument.
<input-function>:
May be any function name that is defined with a result of type BYTE or CHAR, with no arguments.
<error-procedure>:
May be any procedure name that is defined with one and only one BYTE or CHAR argument.
Error routine:
The ERROR routine is used to output messages when there is an unrecoverable runtime error (e.g.: ASSERT failure, memory allocation failure), or in case of a FP error.
For a system failure, the message is an header followed by a single character that indicates the error code:
'HM:1': Heap memory: Overflow (GetMem fails)
'HM:2': Heap memory: Attempt to FreeMem an invalid pointer or FreeMem(X, 0)
'HM:3': Heap memory is corrupted
'FP:4': Floating point: Overflow
'FP:5': Floating point: Underflow
'FP:6': Floating point: Domain error
'7' to '9' are reserved.
For FP errors only: if no ERROR routine is defined, OUTPUT is used. If there is also no OUTPUT, no message is output; then the FP operation is resumed, with FP_FLAGS remaining so that the program may check them. FP_FLAGS remain until an FP_CLR is called.
In all other cases: if no ERROR routine is defined the MCU enters directly the infinite loop.
PMP specificities:
By default nothing is assigned to INPUT, OUTPUT and ERROR pseudo files. If a pseudo file is not assigned, the related console I/O calls will do nothing.
Pseudo files cannot be closed. They may be re-assigned (even with NIL).
{$OPTIMIZE PARAMS OFF}
procedure MyOutput(Ch: char);
…
assign(output, MyOutput); { This will assign the procedure MyOutput for
all further WRITE / WRITELN procedure calls }
See also: ASSERT.