Difference between revisions of "Manual:DIL Manual/continue"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = continue = | |
| − | + | '''Instruction.''' Skips the rest of the loop's statement and starts its next round. | |
| − | |||
| − | |||
| − | + | continue; | |
| − | + | In a [[Manual:DIL Manual/while()|while]] it goes back to the loop's test; in a [[Manual:DIL Manual/foreach()|foreach]] it goes on with the next unit. It acts on the innermost loop around it. | |
| − | + | == Notes == | |
| − | + | * Outside a loop vmc stops with "Using continue outside loop". | |
| − | + | * In a <code>while</code>, take the step before the <code>continue</code>. A <code>continue</code> that skips <code>u := u.next;</code> runs the same round again and again, until the server stops the program for an endless loop. | |
| − | + | == Example == | |
| − | < | + | <pre> |
| − | + | dilbegin carried_weight(); | |
| − | + | var | |
| − | + | u : unitptr; | |
| + | w : unitptr; | ||
| + | n : integer; | ||
| + | code | ||
| + | { | ||
| + | u := self.inside; | ||
| + | while (u != null) | ||
| + | { | ||
| + | w := u; | ||
| + | u := u.next; | ||
| + | if (w.equip != 0) | ||
| + | continue; | ||
| + | n := n + w.weight; | ||
| + | } | ||
| + | exec("say What I carry weighs " + itoa(n) + ", not counting what I wear.", self); | ||
| + | quit; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | Adds up the weight of what an NPC carries but doesn't wear. The step to the next unit comes before the <code>continue</code>. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/break|break]] | |
| − | + | * [[Manual:DIL Manual/while()|while()]] | |
| − | + | * [[Manual:DIL Manual/foreach()|foreach()]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:16, 14 November 2026
Contents
continue
Instruction. Skips the rest of the loop's statement and starts its next round.
continue;
In a while it goes back to the loop's test; in a foreach it goes on with the next unit. It acts on the innermost loop around it.
Notes
- Outside a loop vmc stops with "Using continue outside loop".
- In a
while, take the step before thecontinue. Acontinuethat skipsu := u.next;runs the same round again and again, until the server stops the program for an endless loop.
Example
dilbegin carried_weight();
var
u : unitptr;
w : unitptr;
n : integer;
code
{
u := self.inside;
while (u != null)
{
w := u;
u := u.next;
if (w.equip != 0)
continue;
n := n + w.weight;
}
exec("say What I carry weighs " + itoa(n) + ", not counting what I wear.", self);
quit;
}
dilend
Adds up the weight of what an NPC carries but doesn't wear. The step to the next unit comes before the continue.