The value of count must be a restricted whole number (a scalar or one-element
array). The expression named expression is evaluated
count times. There
are the same limitations on expression as were stated above in the definition
of Monadic Do.
If the expression count is a (perhaps parenthesized) variable name alone or a
parenthesized expression that makes an assignment to a variable name, then within
expression that variable is successively given the integer values 0,
1, ... , count-1 for the successive evaluations. In these cases,
once execution of the do statement is complete, the value of that variable is an integer
equal to the value of the expression count.
If count is (*varname) or (*varnameû...) then execution proceeds
as if the * were not present (including the value of
varname after the do
is completed) and for the successive evaluations of expression the variable is
successively given the same integer values except that these values are given in
decreasing order.
The explicit result of the do statement is the result of the last evaluation of
expression.
Result (ûx) causes an exit from the function that contains the Protected Do.
zû0Ò0
nû10
n do zûz,n ã Variable name alone:
0 1 2 3 4 5 6 7 8 9 ã n is counted up from 0
n ã to its original setting
10
zû0Ò0
(iû10) do zûz,i ã Assignment to a variable name:
0 1 2 3 4 5 6 7 8 9 ã similar treatment of i
i
10
zû0Ò0
vû`i
((%v)û10) do zûz,%v ã Not just a variable name:
10 10 10 10 10 10 10 10 10 10 ã %v remains 10 throughout