endloop
endloop

The endloop statement is used at the end of a loop.

Parameters

No parameters.

Description

The endloop statement is used at the end of a loop. A loop is a sequence of statements that are executed over and over again. The beginning of the loop is always an loop, loopwhile, for, looparray or loopdataarray statement.

When the endloop statement is encountered, Panorama always jumps back to the start of the loop. Use the endloop statement when you have included some other means for stopping the loop. For example the body of the loop could contain a stoploopif or return statement, or you could start the loop with loopwhile, for or looparray.

Here is an example that uses stoploopif to stop the loop.

    local n,word,wl
    wl=0 word="" n=1
    loop
        word=array(Notes,n," ")
        stoploopif  word=""
        n=n+1
        wl=wl+length(word)
    endloop
    message "Average word length is: "+wl/n

This example uses the looparray statement to perform the same calculation.

    local wl
    wl=0
    looparray Notes," ",word,n
        wl=wl+length(word)
    endloop
    message "Average word length is: "+wl/n

Note: In previous versions of Panorama the `endloop` statement was implemented as `while forever` or `while true()`. These alternative loop endings will still work.

Error Messages

ENDLOOP without LOOP – Each ENDLOOP statement must be paired with a corresponding LOOP statement. If this error message appears, the necessary statement beginning the loop has not been included.

See Also

- for -- is used at the beginning of a loop that loops a fixed number of times.
- info("timelimitremaining") -- returns the amount of time available (in seconds) before a loop will time out.
- loop -- is used at the beginning of a loop.
- looparray -- is used at the beginning of a loop that loops over the elements of an array.
- loopdataarray -- is used at the beginning of a loop that loops over the elements of a data array.
- loopindex -- allows a procedure to determine how many times a loop has been repeated.
- loopwhile -- is used at the beginning of a loop.
- Preventing Endless Loops -- setting up a timeout limit to prevent endless loops.
- repeatloopif -- decides whether to continue with a loop or to start over again from the top.
- stoploopif -- decides whether to continue with a loop or to exit the loop immediately.
- timelimit -- specifies the maximum time a procedure can continue to run after this statement.
- until -- is used at the end of a loop, and can control how many times the loop is executed.
- while -- is used at the end of a loop, and can control how many times the loop is executed.

History

Version | Status | Notes
10.0 | New | New in this version