loopindex
loopindex
VARIABLE

The loopindex statement allows a procedure to determine how many times a loop has been repeated.

Parameters

This statement has one parameter:

variable – is the name of a field or variable where the loop count will be stored. If this field or variable does not already exist, it will be created as a local variable.

Description

Panorama keeps track of how many times the statements inside a loop have been executed. If your procedure needs to access this value, it can do so with the loopindex statement. In this example, ten new records are added to the database. Using the loopindex statement, the Num field in the new records will be assigned a number from 1 to 10 as the records are added.

    loop
        addrecord
        loopindex Num
    until 10

Note: If the specified field or variable does not exist, Panorama will automatically create a local variable for you. In the example below, a local variable named n is automatically created (assuming there is no field or global variable named n that has already been created).

    loop
        loopindex n
        addrecord
    until n>=10

Error Messages

LOOPINDEX must be used between LOOP and ENDLOOP statements – The loopindex statement can only be used inside a loop.

LOOPINDEX parameter must be a field or variable – The parameter supplied to the loopindex statement must be the name of a field or variable, it cannot contain any calculations or operators of any kind.

See Also

- endloop -- is used at the end of a loop.
- 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.
- 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