Rational Developer for System z
PL/I for Windows, Version 7.6, Programming Guide

Using ON ANYCONDITION

Any application should be able to handle all exceptions that occur within it and return 'normal' control to the calling program. PL/I exception-handling facilities and ANYCONDITION ON-units help make this possible.

The first executable statement in any PL/I routine that is called from a non-PL/I routine should be an ON ANYCONDITION statement. This statement should contain code to handle any condition not handled explicitly by other ON-units. If a condition arises that cannot be handled, use a GOTO statement pointing to the last statement that would normally be executed in the routine, for example:

  pliapp:
    proc( p1, ...,  pn )
    returns( ... )
    options( fromalien );

  /* declarations of paramaters, if any */

  /* declarations of other variables    */

  on anycondition
    begin;
      /* handle condition if possible   */

      /* if unhandled, set return value */
      goto return_stmt;
    end;

  /* mainline code */

  return_Stmt:
  return( ... );

  end_stmt:
  end pliapp;

For PL/I routines that are not functions, the target for the GOTO should be the END statement in the routine.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)