TAL Programmer's Guide
ASSERT Statement
Controlling Program Flow
096254 Tandem Computers Incorporated 12–17
ASSERT Statement The ASSERT statement conditionally invokes the procedure named in an ASSERTION
directive. It is a debugging or error-handling tool.
To specify the ASSERT statement, include:
ASSERT assert-level
Specifies an integer in the range 0 through 32,767, followed by a colon. If the
assert-level is equal to or higher than the assertion level specified in the current
ASSERTION directive and if the condition is true, the compiler activates the
procedure specified in the ASSERTION directive. If the assert-level is lower than
the assertion level, the procedure is not activated.
condition
An expression that tests a program condition and yields a true or false result.
For example, this ASSERT statement specifies an assert-level of 7 and the expression
$CARRY, which tests a program condition:
ASSERT 7 : $CARRY;
$CARRY is a standard function that tests the state of the carry indicator. If the carry
indicator is on, $CARRY returns a true; if it is off, it returns a false. The carry indicator
is set when a scan resulting from a SCAN or RSCAN statement is stopped by a 0. It is
also set by some arithmetic operations.
Using ASSERT
with ASSERTION
You use the ASSERT statement with the ASSERTION directive as follows:
1. Place an ASSERTION directive in the source code where you want to start
debugging. In the directive, specify an assertion-level and an error-handling
procedure such as the D-series PROCESS_DEBUG_ or the C-series DEBUG system
procedure. The assertion-level is an integer in the range 0 through 32,767:
?ASSERTION 5, PROCESS_DEBUG_ !Assertion-level is 5
2. Place an ASSERT statement at places where you want to invoke the error-handling
procedure when an error occurs. In the statement, specify an assert-level that is
equal to or higher than the assertion-level and specify an expression such as
$CARRY that tests a program condition:
ASSERT 10 : $CARRY; !Assert-level is 10
3. During program execution, if an assert-level is equal to or higher than the current
assertion-level and condition is true, the compiler activates the error-handling
procedure.
4. After you debug the program, you can nullify all or some of the ASSERT
statements by specifying an ASSERTION directive with a higher assertion-level
than the ASSERT statements you want to nullify:
?ASSERTION 11, PROCESS_DEBUG_
!Assertion-level nullifies
assert-level
10 and below