You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
4.12 FOR ADVANCED USERS. 72<br />
where 〈variable〉 is as before, while 〈start〉, 〈delta〉 and 〈stop〉 are numeric values. If 〈delta〉 is<br />
positive the loop is skipped entirely if 〈stop〉 is less than 〈start〉. Otherwise the loop is executed<br />
successively with the variable equal to 〈start〉, then 〈start〉 + 〈delta〉 then 〈start〉 + 2〈delta〉, etc., as<br />
long as the variable is not greater than 〈stop〉. The behavior is similar if 〈delta〉 is negative, except<br />
the loop is repeated only as long as the variable is not less than 〈stop〉. If 〈delta〉 is 0, then the<br />
METAFONT run will generate an error.<br />
Note that the index variable (center and radius in the above two examples) is a temporary<br />
METAFONT variable. If mplabels is turned on, this variable will work as expected in the location<br />
parameter of a \tlabel command, but if it is used in the label part, it will be interpreted as TEX<br />
code and printed as is. The index variable reverts to its previous state outside the loop. That is, if it<br />
existed before the loop, it regains its previous value after the loop, and if it was undefined before the<br />
loop, it is again undefined after.<br />
The single word ‘upto’ can be used as an abbreviation for “step 1 until” and ‘downto’ for<br />
“step -1 until” in for-loop headers. Spaces are not significant in for-loop headers, except to<br />
distinguish the keywords (e.g. step) from variable names that might be used (e.g., for 〈start〉).<br />
\mfpwhile{〈condition〉}<br />
〈MFPIC commands〉<br />
\endmfpwhile<br />
The 〈condition〉 should be an expression that can be either true or false about a METAFONT<br />
variable that changes at some time during the loop body. The loop body is executed (by METAFONT)<br />
as long as the condition is true. Example:<br />
\setmfvariable{numeric}{R}{20}<br />
\mfpwhile{R > 1}<br />
\rect{(0,0), (R,3R)}<br />
\mfcmd{R:=R/2}<br />
\endmfpwhile<br />
There are no MFPIC commands to systematically change a variable, so in this example we have<br />
resorted to directly writing a METAFONT assignment command via \mfcmd (see subsection 4.12.3<br />
above) that reduces R by half. The loop will be executed with R having the successive values 20,<br />
10, 5, 2.5, and 1.25. The resulting picture could have been achieved with \mfpfor using this list of<br />
values.<br />
\mfploop<br />
〈MFPIC commands〉<br />
\mfpuntil{〈condition〉}<br />
〈MFPIC commands〉<br />
\endmfploop<br />
The body of this loop will be repeated until the 〈condition〉 becomes true. The condition should<br />
be some expression that can be either true or false about a variable that changes during the loop execution.<br />
It should eventually become true. If an mfploop environment does not contain an \mfpuntil<br />
command, then the \endmfploop command will generate a warning message. If the warning is ignored,<br />
and the user has not otherwise arranged for loop termination, 19 the .mf file will contain an<br />
infinite loop. The \mfpuntil command will break the loop at whatever point it occurs. Example:<br />
19 Perhaps by means of \mfsrc commands. It is because of this possibility that only a warning is produced and not an error.<br />
If the warning becomes annoying, adding \mfpuntil{false} to the loop will silence it. This command will never break the<br />
loop because the condition false (of course) never becomes true.