On this page:
The REPEAT Command, REPEAT n Loops.
You can skip this page withput missing too much -- REPEAT is mostly a leftover from before Hypatia had an input editor that let you scroll back to previous inputs, and from before the DO loop command.
Still, you may find REPEAT convenient in some cases.
REPEAT can be used on its own, or followed by a number.
REPEAT without a number repeats the most recent calculation, variable assignment, user defined element assignment, or script execution -- it does this by reading the file hyin and using it as the input line.
Loops cannot be repeated!
In case an input line is a DO loop, only the part that gets executed in the loop -- that is, what comes after the double colons -- is saved to hyin and will be repeated by REPEAT.
You can use REPEAT repeatedly, and, if you need to, you can use the command EDIN to open the file hyin in the chosen editor (see page "Editing Files" in chapter "The Basics") -- REPEAT will then use the edited version.
If the most recent line has called a script you can of course edit that script before the next REPEAT.
If you edit the file hyin, close the file in the editor or close the editor before you continue to work with Hypatia.
REPEAT on its own is not a loop command. If it calls a script, the loop index I will be 1 (as it is outside of loops), and the variable ISLOOP will be zero.
Like DO, REPEAT cannot be used in a script, or after an I1:, I*:, IF ... THEN, ALSO: and ELSE: condition.
REPEAT n (where n is a number) executes the line in the file hyin n times -- this is a loop, even when n is 1. REPEAT * is an infinite loop.
REPEAT loops and DO loops are basically the same, with one difference regarding the loop index: Because a REPEAT loop repeats a line that has already been executed, in each REPEAT loop the loop index I starts with the value 2, not 1.
Also, the maximum number of loops is one less than the value of MAXLOOP.
REPEAT n executes the line n times, not n minus 1.
Home, Up: Loops, Prev: Exiting a Loop, Next Chapter: Loop and Script Examples