Version 6.3.8 for OpenVMS
 —  Statements  —

LOOP

[CLOSELOOP [(r)]    

This document covers the following topics:


Function

The LOOP statement is used to close a processing loop. It causes processing of the current pass through the loop to be terminated and control to be returned to the beginning of the processing loop.

When the processing loop for which the LOOP statement is issued is terminated (that is, when all records have been processed or iterations have been performed), execution continues with the statement after the LOOP statement.

Database Variable References

A LOOP statement, in addition to closing a processing loop, will eliminate all field references to FIND, FIND FIRST, FIND UNIQUE, READ and GET statements contained within the loop.

A field within a view may be referenced outside the processing loop by using the view name as a qualifier.

Top of page

Restriction

Top of page

Syntax Description

Syntax Element Description
LOOP (r)
Statement Reference Notation:

The LOOP statement may be specified with a statement label or reference number (notation (r)), in which case all inner loops up to and including the loop initiated by the statement referenced will be closed. If no statement reference is specified, the innermost active processing loop will be closed.

Note:
In reporting mode, any processing loop which is currently active, that is, which has not explicitly been closed with a LOOP statement, will be closed automatically by an END statement.

Top of page

Examples

Example 1

FIND ...
  READ ...
    READ ...
LOOP (0010)    /* closes all loops

Example 2

FIND ...
  READ ...
    READ ...
    LOOP       /* closes loop initiated on line 0030  
  LOOP         /* closes loop initiated on line 0020
LOOP           /* closes loop initiated on line 0010

Top of page