next up previous contents index
Next: Local Keywords Up: MIDAS Command Language Previous: Symbol Substitution in Command

   
DO Loops

Loops  are supported in MIDAS procedures like the DO loops in FORTRAN (but note that loops are always executed at least once):

!+
! 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 N$\leq$6 in steps of 2
WRITE/OUT N =
$\{$N$\}$
ENDDO
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.
  
The command @@ exa9 will yield
N = 0001
N = 0003
N = 0005
Assume 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:
!+
! 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
$\{$P2$\}$$\{$N$\}$ = $\{$P1$\}$$\{$NN(2)$\}$+$\{$P1$\}$$\{$NN(1)$\}$! sum up
LOAD/IMAGE
$\{$P2$\}$$\{$N$\}$! display the result frame
ENDDO
Then, the MIDAS command @@ exa10 imag res will do the required task.


next up previous contents index
Next: Local Keywords Up: MIDAS Command Language Previous: Symbol Substitution in Command
Petra Nass
1999-06-09