Loops are supported in MIDAS procedures like the DO loops in FORTRAN (but note that loops are always executed at least once):
!+A keyword of integer type (called N in our example) must be used to store the loop variable. The parameters follow the standard FORTRAN conventions with start (=1 in exa9.prg), end (=6) and in/decrement (=2) values given as shown above. DO loops may be nested up to 8 levels deep in a procedure.
! Example 9, MIDAS procedure exa9.prg
!+
WRITE/KEYWORD N/I/1/1 0 ! keywords serve as loop variables
DO N = 1 6 2 ! loop from N=1 until N6 in steps of 2
WRITE/OUT N = N
ENDDO
N = 0001Assume we have images imag0001.bdf to imag0100.bdf and want to add successive pairs and store the results into images res0001.bdf to res0050.bdf:
N = 0003
N = 0005
!+Then, the MIDAS command @@ exa10 imag res will do the required task.
! Example 10, MIDAS procedure exa10.prg
!+
DEFINE/PARAM P1 ? IMA "Enter root_name for input frames: "
DEFINE/PARAM P2 ? IMA "Enter root_name for output frames: "
DEFINE/MAXPAR 2 ! max. 2 parameters expected
SET/FORMAT I4 ! we need 4 digits
WRITE/KEYWORD N/I/1/1 0
WRITE/KEYWORD NN/I/1/2 0,0
!
DO N = 1 50 ! default increment is 1
NN(1) = 2*N
NN(2) = NN(1)-1
COMPUTE/IMAGE P2N = P1NN(2)+P1NN(1)! sum up
LOAD/IMAGE P2N! display the result frame
ENDDO