Previous Topic Next topic Print topic


BEGIN

Purpose

Groups a set of program statements and defines a scope for the names declared within it.

Syntax

BEGIN[ORDER|REORDER];

Description

The BEGIN statement defines a begin block and indicates the start of that block. The block must end with an END statement.

The BEGIN statement is an executable statement that may appear as a THEN clause or as an ELSE clause of an IF statement, as an ON-unit of an ON statement, or as a simple statement anywhere in a procedure.

When the BEGIN statement executes, it activates the begin block. The block activation terminates when the corresponding END statement executes, when a RETURN statement executes (which terminates the enclosing procedure), or when a GOTO statement that references a label external to the block executes.

Since the execution of a BEGIN statement incurs the additional time and space overhead needed to set up a block activation, a simple DO group is preferred for elementary statement bracketing. Note, however, that the DO group cannot serve as an ON-unit, nor does it introduce a new scope for declarations. The BEGIN statement must be used in such instances.

ORDER and REORDER are options sometimes used for optimization in IBM mainframe PL/I programs. They are not needed by Open PL/I; these options are simply parsed and otherwise ignored by Open PL/I.

Example

BEGIN;
   .
   .
   .
END;
ON ERROR 
   BEGIN;
      .
      .
      .
   END;

Restrictions

None.

Previous Topic Next topic Print topic