# CDC Community

πΉ Historical Conservation πΉ

### Site Tools

tutor:conditional_iterative_do

# The Conditional Iterative -do-

The conditional and iterative -do- can be combined so that, on each iteration, the conditional expression selects which unit to do this time:

do N+3,ua,ub,uc,ud,iβ1,12 βexpβ<0β0β1 ββ₯2

For each value of i (from 1 to 12), the expression βN+3β is evaluated, which determines which subroutine will be done. For example, if βN +3β is 0, the above statement is equivalent to βdo ub,iβ1,12β. Usually a conditional iterative -do- is used in situations where the conditional expression (βN +3β ) is not changing, but doing one of the subroutines can change N so that a different subroutine is used on the next iteration. The following is an example of such manipulations:

do i-2,ua,ub,uc,ud,iβ1,4

In the first case, where i is equal to 1, the condition βi-2β is -1, so we do βuaβ. Then i is incremented to 2, and we do βubβ, etc. This is, therefore, equivalent to the sequence:

do ua do ub do uc do ud

As usual, the specified units can involve the passing of arguments.

In a conditional non-iterative -do- the unit names βxβ and βqβ mean βdon't do anythingβ and βgoto qβ respectively. In a conditional iterative -do-, βxβ means βdon't do anything on this iteration,β and βqβ means βquit doing this statement and go on to the next statement.β In other words, βxβ means βfall through to the next iteration,β while βqβ means βfall through to the next TUTOR statement.β For example:

do i-2,ua,x,q,ud,iβ1,4 show i

will display the number β3β. For i equal to 1 we do βuaβ; for i equal to 2 we do nothing; for i equal to 3 we quit and go on to the following -show- statement.