# 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⇑<001≥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. 