HOME GUIDE OPERATIONS DOCS FAQ TECHNIQUES FORMATS INSTALL NEW TIPS WEB LINKS Wadsworth Labs

DO - Start of DO loop (Scripting operation)

(11/7/06)

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.

SEE ALSO

ENDDO [End of DO 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 .

Variable Value Input In DO-Loops:

NOTE: IF THIS FEATURE IS NOT TO BE USED, THEN ALL NUMERICAL INPUT
VALUES TO EACH OPERATION ARE TO BE ENCLOSED IN PARENTHESES.

The same sequence of operations can be applied with different parameter values to the same image.

For variable parameter input values may be entered in sequence, to be picked according to the DO-loop count. Example:

DO [num]=1,3
SH
PIC{***[num]}
OUT{***[num]}
4., 5., 2.3, 1.2, -7.1, 8.2
ENDDO

In this example, 'SH' uses the shift vector (4., 5.) with the picture PIC001, (2.3, 1.2) with PIC002, and (-7.1, 8.2) with PIC003.

In the case of operations requiring a pair of numbers (e.g., shift coordinates), one pair has to be provided for each run of the DO-loop. However, if the same floating point number or pair of numbers should be used for each run of the DO-loop, this may be specified by using a single number (or pair of numbers) enclosed in parentheses. Example:

DO [num]=5,9
SH
ALL{***[num]}
SHI{***[num]}
(15,8)
ENDDO

In this case, the shift parameter values 15,8 are applied to each image, starting with ALL005 and ending with ALL009.

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 symbolic or register variables. For example:
    DO [image]=[start],[end],[incr]
    is allowed. 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 earlier syntax is often 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.

SUBROUTINES

SPIDER, FINDLBQ, GETLBNO

CALLER

SPIDER

© Copyright Notice /       Enquiries: spider@wadsworth.org