Difference between revisions of "Manual:DIL Manual/clear()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = clear() = | |
| − | + | '''Procedure.''' Removes an interrupt set up with interrupt(). | |
| − | + | clear(i : integer); | |
| − | |||
| − | + | Removes interrupt number <code>i</code> of the running template, the number that [[Manual:DIL Manual/interrupt()|interrupt()]] returned. The program then no longer jumps to that interrupt's label. | |
| − | < | ||
| − | |||
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| + | ! Name !! Type !! Meaning | ||
| + | |- | ||
| + | | i || integer || The interrupt's number, as returned by <code>interrupt()</code>. | ||
| + | |} | ||
| − | + | == Notes == | |
| + | * A number that isn't in use does nothing. | ||
| + | * The interrupts after the cleared one move down a place, so their numbers change: interrupt 2 becomes 1 after <code>clear(1)</code>. Clearing several, clear the highest number first, or set them up again. | ||
| + | * It only reaches the interrupts of the template that runs <code>clear</code>, not those of a template that called it. | ||
| + | * Running the same <code>interrupt()</code> statement again replaces the old one, so there is no need to clear it first. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | dilbegin guard_post(); | ||
| + | var | ||
| + | i : integer; | ||
| + | code | ||
| + | { | ||
| + | heartbeat := PULSE_SEC * 30; | ||
| + | i := interrupt(SFB_MSG, argument == "stand down", relieved); | ||
| + | |||
| + | :loop: | ||
| + | wait(SFB_TICK, TRUE); | ||
| + | act("$1n looks around watchfully.", A_SOMEONE, self, null, null, TO_ROOM); | ||
| + | goto loop; | ||
| + | |||
| + | :relieved: | ||
| + | clear(i); | ||
| + | act("$1n relaxes and sits down.", A_SOMEONE, self, null, null, TO_ROOM); | ||
| + | pause; | ||
| + | act("$1n stands up and goes back to the post.", A_SOMEONE, self, null, null, TO_ROOM); | ||
| + | i := interrupt(SFB_MSG, argument == "stand down", relieved); | ||
| + | goto loop; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | An NPC on guard that takes a break when told "stand down"; while it rests, the message does nothing. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/interrupt()|interrupt()]] | ||
| + | * [[Manual:DIL Manual/wait()|wait()]] | ||
Latest revision as of 23:17, 14 November 2026
clear()
Procedure. Removes an interrupt set up with interrupt().
clear(i : integer);
Removes interrupt number i of the running template, the number that interrupt() returned. The program then no longer jumps to that interrupt's label.
Parameters
| Name | Type | Meaning |
|---|---|---|
| i | integer | The interrupt's number, as returned by interrupt().
|
Notes
- A number that isn't in use does nothing.
- The interrupts after the cleared one move down a place, so their numbers change: interrupt 2 becomes 1 after
clear(1). Clearing several, clear the highest number first, or set them up again. - It only reaches the interrupts of the template that runs
clear, not those of a template that called it. - Running the same
interrupt()statement again replaces the old one, so there is no need to clear it first.
Example
dilbegin guard_post();
var
i : integer;
code
{
heartbeat := PULSE_SEC * 30;
i := interrupt(SFB_MSG, argument == "stand down", relieved);
:loop:
wait(SFB_TICK, TRUE);
act("$1n looks around watchfully.", A_SOMEONE, self, null, null, TO_ROOM);
goto loop;
:relieved:
clear(i);
act("$1n relaxes and sits down.", A_SOMEONE, self, null, null, TO_ROOM);
pause;
act("$1n stands up and goes back to the post.", A_SOMEONE, self, null, null, TO_ROOM);
i := interrupt(SFB_MSG, argument == "stand down", relieved);
goto loop;
}
dilend
An NPC on guard that takes a break when told "stand down"; while it rests, the message does nothing.