DO - Start of a loop (Scripting operation)

(2/17/15)

PURPOSE

To allow repetitive execution of sections of the SPIDER operation stream. Operations inside a loop can be repeated a defined number of times with a varying index value. Modeled after FORTRAN 'DO' syntax.   Example.

SEE ALSO

ENDDO [End of DO loop (Scripting operation)]
CYCLE [Starts next loop iteration (Scripting operation)]
EXIT [Ends execution of current operation loop (Scripting operation)]
LB [Label for jump operation or end of DO-loop (Scripting operation)]

USAGE

.OPERATION: DO <REG>=<LOWER>,<UPPER>,<INCREMENT>
~~~~~~~
~~~~~~~
ENDDO

Where:
1. <REG> is a loop index variable where the value of the index is accumulated. (SPIDER still accepts an earlier syntax where <REG> was a single letter (a...z or A..Z) which denotes the loop index).
2. <LOWER> is a integer constant that specifies the lower bound of the loop index.
3. <UPPER> is a integer constant that specifies the upper bound of the loop index.
4. <INCREMENT> is an optional integer constant that specifies an incremental value that is added to the loop index with each cycle of the loop. Default value for <INCREMENT> is 1.

EXAMPLE:

DO [imgnum]=5,17
~~~~~~~
~~~~~~~
ENDDO

In the above example, DO will repeat any operations (~~~~~) with the loop index variable [imgnum] varying from 5 to 17.

Nesting of DO loops is allowed. For example:

DO [xval]=2,3
~~~~~~~
~~~~~~~
DO [yval]=5,15,5
~~~~~~~
~~~~~~~
ENDDO
~~~~~~~
~~~~~~~
ENDDO
will perform the operations within the initial loop 2 times, and the operations within the enclosed loop a total of 6 times.

NOTES

  1. When nesting DO loops, make sure that different registers are used for <REG>.

  2. DO loops may be nested up to a maximum of MAXPRC deep. See: 'CMLIMIT.INC for current value of MAXPRC.

  3. Any number of operations may appear between 'DO' and 'ENDDO'.

  4. The lower, upper bounds, and increment of the 'DO LOOP' operation may be either string or register variables. For example:
    DO [image] = [start],[end],[incr]
    is allowed where: [start] = '1'.
    We advise against using non-integers for these values as their usage may vary in the future.

  5. Prior to SPIDER release 15.0, 'DO' loops were terminated with a label operation 'LB'. This label had to be specifed when invoking the loop. This syntax is found in older SPIDER procedures and is still supported but is now deprecated. Example:
    DO LB4 [num]=1,9
    SH
    ALL{***[num]}
    SHI{***[num]}
    (15, 8)
    LB4

  6. More information on DO-loops.

  7. In legacy SPIDER procedures the default interpretation of input values to operations within a 'DO LOOP' was that values NOT enclosed in sets of '()' were applied over successive steps of the loop. This was a confusing feature, and should never have been part of SPIDER. See the user guide for an explanation of this capability and the current method how to apply differing values on successive steps of the DO LOOP. It is simpler to just ignore this capability since one rarely needs to apply such a limited set of different values on successive steps within a DO LOOP.

SUBROUTINES

SPIDER, FINDLBQ, GETLBNO

CALLER

SPIDER

© Copyright Notice /       Enquiries: spider@wadsworth.org