Manual:DIL Manual/skip
Contents
skip
Keyword. Takes the place of a label in an interrupt or an on ... goto, and means "don't jump".
on_activation(condition, skip); interrupt(flags, condition, skip); on expression goto label0, skip, label2, ...;
skip is accepted in two places only: as the label of interrupt() (and of on_activation(), which is interrupt(SFB_ACTIVATE, ...), a macro in wmacros.h), and in the label list of on ... goto.
In an interrupt, skip means: while the condition holds, ignore the event. The program isn't run for it and stays in the wait it was in. The event is lost, not queued, and the unit's other programs still get it. The usual use is a guard at the top of a program: asleep or fighting, ignore everything.
In on ... goto, a skip entry means: for this value, don't jump; go on with the statement after the on, as for a value outside the list.
Notes
skipis a reserved word: it can't name a variable or a label, andgoto skip;is a syntax error.- The condition is tested at every wake of the program (
check_interruptin dilrun.cpp), before the program sees the event. - An on_activation() with a label is cleared when it jumps; one with
skipstays until the template returns or clear() removes it. on_activation() returns the interrupt's number for clear(), as in haon_dor.zon:intridx := on_activation(self.position <= POSITION_SLEEPING, skip); - The condition is evaluated in full (
andandordon't short-circuit), and a field of a null unit is false, soactivator.position <= POSITION_SLEEPINGis false when there is no activator.
Example
dilbegin fortune();
var
i : integer;
code
{
on_activation((self.position <= POSITION_SLEEPING) or
(self.position == POSITION_FIGHTING), skip);
heartbeat := PULSE_SEC * 30;
:start:
wait(SFB_TICK, TRUE);
i := rnd(0, 3);
on i goto good, skip, bad;
exec("say The stars are silent today.", self);
goto start;
:good:
exec("say Fortune smiles on you.", self);
goto start;
:bad:
exec("say Beware the dark.", self);
goto start;
}
dilend
A fortune teller who speaks every 30 seconds while awake and not fighting. When rnd() gives 1 (skip) or 3 (past the end of the list), the on falls through to the line after it.