TIMES is a variant of MANY that expects the number of times Forth should execute the following text.
0 VALUE #TIMES \ Counter
: TIMES ( n -- )
#TIMES 1+ TUCK ( #times+1 n #times+1 )
0 TO #TIMES \ Let's be careful.
= STOP? OR \ n-th time or STOP?
IF DROP EXIT THEN \ We're through.
TO #TIMES 0 >IN ! ; \ Increment counter..
\ ..and again.
) BL [rtn]
) DUP EMIT 1+ 96 TIMES DROP [rtn] ?
The number of times Forth should restart the line is passed on the stack to TIMES. The value #TIMES is an internal variable used by TIMES. When this variable is inadvertedly initialized to -100 or worse, to 100 ...
|