Search                        Top                                  Index
HELP LOOPS                                    J. L. Cunningham July 1982
                                         Revised: Adrian Howard Mar 1992
                                                   Revised A.S. May 2012

The usual way to make POP-11 do some instructions several times
(iteration) is to use loops (also called iterative constructs). See:

    *FOR        --- Iteration over lists and structures
        (The HELP *FOR file presents a variety of loop forms including
        parallel iteration over different lists)
    *FOREACH    --- Selective iteration over a database, using pattern
    *FOREVERY   --- Like -foreach-, but matches a list of patterns,
        coping with all possible combinations of matches (except for
        segment variables using "??")
    *REPEAT     --- Repeats a set of actions indefinitely
                        (but see "quit" options below)
    *REPEAT N TIMES --- Repeats a set of actions a specified number of times
    *WHILE      --- Repeats a set of actions while a condition is -true-
    *UNTIL      --- Repeats a set of actions until a condition is -true-

Loops can be interrupted, conditionally or unconditionally, see:

    *QUITLOOP   --- to jump out of one or more enclosing loops
    *QUITIF     --- to jump out of a loop if a condition becomes -true-
    *QUITUNLESS --- to jump out of a loop if a condition becomes -false-
    *NEXTLOOP   --- to continue an enclosing loop (start next iteration)
    *NEXTIF     --- to restart a loop if a condition becomes -true-
    *NEXTUNLESS --- to restart a loop if a condition becomes -false-

All the above can take an extra integer argument specifying that the Nth
enclosing loop should be terminated or continued. The *RETURN command
terminates the execution of the current procedure, and also jumps out of
any loops.

See HELP *FOR_FORM for information on creating new looping constructs.

For alternatives to the above see:

    *APPLIST    --- Applies a procedure to each element of a list
    *MAPLIST    --- As -applist-, but returning a changed copy of list
    *RECURSION  --- A short introduction to recursion techniques
    *GOTO       --- Transfers control within a procedure (NOT
    *GO_ON      --- Jump to one of a list of labels
    *SWITCHON   --- A 'case' construct

Also see:

    HELP *CONTROL   --- Information on POP-11 control structures

    REF *FASTPROCS  --- Information on non-checking iteration
    REF *POPSYNTAX  --- Syntax diagrams for POP-11.
    REF *SYNTAX     --- More on POP-11 syntax

--- $usepop/pop/help/loops
--- Copyright University of Sussex 2012. All rights reserved. ----------