loopdataarray
loopdataarray
ARRAY
,
ELEMENT
,
INDEX

The loopdataarray statement is used at the beginning of a loop that loops over the elements of a data array.

Parameters

This statement has three parameters:

array – is the data array to be scanned.

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

index – 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. (Note: This parameter is optional – if you don’t need to know the loop count, you can leave this parameter off.

Description

The loopdataarray statement is used at the beginning of a loop that iterates over a data array (see Data Arrays and Loop for more information on these topics). LoopDataArray loops are always terminated with an endloop statement.

When the loop starts, Panorama calculates the data array and makes a copy of it. Each time through the loop Panorama extracts the next element from the array for processing. In other words, the first time through the loop the first element is processed, then the next time through the second element is processed, etc. The loop repeats until all of the array elements have been processed.

Here is a simple example that loops once for each item in the Stuff data array, and displays the item.

    loopdataarray Stuff,item
        message item
    endloop

Adding a third parameter to the loopdataarray statement allows you to access the number of times the loop has repeated so far.

    loopdataarray Stuff,item,itemnumber
        message itemnumber+": "+item
    endloop

Note: If the data array is empty, the statements in the loop are skipped without even executing them once.

Error Messages

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

LOOPDATAARRAY element parameter must be a field or variable – The ELEMENT parameter must be a field or variable, it cannot be a more complex calculation.

LOOPDATAARRAY index parameter must be a field or variable – The INDEX parameter must be a field or variable, it cannot be a more complex calculation.

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.
- 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