The format of the keepon statement is:
keepon ( Number-expression )
The keepon statement repeats the loop for the number of times determined by the number expression. After looping the specified number of times, execution moves to the next of the endkeepon.
If the execution reached "continue" or "endfromto", execution moves to the first statement of the keepon after updating the loop index.
If the execution reached "break", execution moves to the next of the endkeepon.
A keyword that indicates that it is a keepon statement.
The number expression is an expression for determining the number of loops in a keepon statement.
The number expression is an expression that returns the int and its value must be greater than or equal to 1.
If the number expression is less than or equal to zero, the loop will not be executed.
If the number expression returns a proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.
proxy pro = new proxy(10);
keepon(pro) // pro.Entity is used.
The entity of the proxy must be an int class.
♦1: At the beginning of the keepon statement, the number of loops is determined from the number expression and the loop index is initialized to zero. This is done only once at the beginning. If the number expression is less than or equal to zero, the number of loops will be zero.
♦2: The number of times is judged. If the loop index and the number of loops are equal, the execution is moved to the next of the endkeepon.
♦3: The statements within the keepon are executed.
♦4: When the execution reaches the "continue" or "endkeepon", the loop index is incremented.
♦5: the execution goes back to the ♦2.
The keepon statement generates a scope.
Variables declared in the scope are re-declared per loop and new instances are assigned.
It does not carry over the value of the previous loop to the next loop.
When execution reaches the keepon, a scope is generated and the reserved variables __index and __count are defined.
__index and __count are variables of the int class. It is initialized with the number of loops starting from zero.
The scope has already been generated when evaluating the number of times. Therefore, if you used a reserved variable in the evaluation, the reserved variable is the one defined by the current keepon statement.
The statements within a keepon statement are optional. You can place statements as many as you want.
It is a keyword that indicates the end of the keepon statement.
You can use the abbreviation "eko" instead of "endkeepon". Note that "eko" is also a keyword.
open method void someMethod()
message m; // dialog box.
m.Show(__index); // 0, 1, 2, 3, 4