Program Control Procedures [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
Program Control Procedures
The only program control procedures supported by HP Pascal are halt and
assert. The details of these procedures are given below.
halt
Usage
halt(n)
halt
Parameter
n An integer expression that may be omitted.
Description
This procedure terminates the execution of the program. What this means
and what is done with the optional integer expression is implementation
defined. For more information, see the HP Pascal/iX Programmer's Guide
or the HP Pascal/HP-UX Programmer's Guide, depending on your
implementation.
Example
halt
halt(int_exp)
assert
The predefined procedure assert allows your program to test assumptions,
specify invariant conditions, and check data structure integrity.
Usage
assert (b, i [, p])
Parameters
b A Boolean expression that assert evaluates. If its value is
true, the program executes the statement following the call to
assert. If its value is false, the program's action depends
upon whether p is specified and whether the ASSERT_HALT
compiler option is OFF or ON (see Figure 11-1 ).
If the compiler can determine that b is a constant expression
whose value is true, then it does not generate code for the
call to assert.
i An integer expression. If the value of b is false and p is
specified, procedure p is called with i as the actual value
parameter. If b is false and p is not specified, the system
issues a run-time error message that includes the value of i.
A call to the predefined function statement_number is a useful
integer expression for i. It returns the statement number (as
shown on the compiler listing) for the statement from which it
is called (in this case, the call to assert).
p The name of a procedure whose heading has the syntax
PROCEDURE p (parameter_name : integer);
If the value of b is false and p is specified, the system
executes the call p(i).
The default for the ASSERT_HALT compiler option is OFF (see Chapter 12
for more information).
Example
PROCEDURE my_assert (value : integer);
BEGIN
writeln('my_assert #', value);
END;
PROCEDURE x (p : ptrtype; n : integer);
BEGIN
assert(p <> nil, 80101, my_assert);
assert(n >= 0, 80102);
END;
MPE/iX 5.0 Documentation