CDC Community

πŸ”Ή Historical Conservation πŸ”Ή

User Tools

Site Tools


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.

The -if- and -else- Commands

tutor/conditional_iterative_do.txt Β· Last modified: 2022/08/25 14:31 by