Difference between revisions of "Manual:DIL Manual/interrupt()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
(XML import)
 
Line 1: Line 1:
 
 
 
<span id="bpinterr"></span>
 
<span id="bpinterr"></span>
 
  integer interrupt( flags : integer, dilexp, label )
 
  integer interrupt( flags : integer, dilexp, label )
Line 38: Line 36:
  
 
  code
 
  code
  {
+
dilend</nowiki>
  /* Notice that the sequence in which the interrupts (and the on_activation)
+
 
    are executed, is quite important: You can be cured at *any* time. The
+
  ---~---~---~---~---~---~---~---~---
    program will skip if you are not sleeping. If you are sleeping you can
+
<span id="bpinterr"></span>
    be relieved. */
+
integer interrupt( flags : integer, dilexp, label )
 +
 
 +
    Set up interrupt matching message classes matching "flags",
 +
    for example "SFB_COM" or "SFB_COM | SFB_MSG".
 +
 
 +
    When the program is activated on either of the specified conditions
 +
    the 'dilexp' is evaluated. If true, then execution continues at 'label',
 +
    otherwise the next interrupt is checked (if any).
 +
 
 +
    Interrupts are saved (restored), when 'recall' is set.
 +
    Returns an integer which is used for clear() to clear an interrupt.
 +
 
 +
'''Example:'''
  
    interrupt(SFB_MSG, argument == "cured", the_end);
+
The following program shows, that the owner (self) of the program keeps
 +
snoring while sleeping. The on_activation ensures that the program
 +
is only activated when the owner is sleeping. However, since the interrupt
 +
precede the on_activation, these may still be intercepted before the
 +
on_activation. The on_activation is just another type of interrupt that
 +
reacts on all flags (without actually setting them so that the program
 +
is activated).
  
    on_activation(self.position != POSITION_SLEEPING, skip);
+
When the program receives the message "relief" the snoring stops briefly.
 +
As used, "relief" may only be set once.
  
    i1 := interrupt(SFB_MSG, argument == "relief", relief);
+
When the program receives the message "cured", the snoring stops completely
 +
(i.e. the program quits itself).
 +
 
 +
<nowiki>
  
    :loop:
+
dilbegin
    exec("snore", self);
 
    pause;
 
    goto loop;
 
  
     :relief:
+
var
    /* Suppose you can only be relieved once, then we must clear interrupt */
+
     i : integer;
    clear(i1);
 
    pause;
 
    pause;
 
    goto loop;
 
  
    :the_end:
+
  code
    /* Person is cured... */
+
dilend</nowiki>
    quit;
 
  }
 
dilend</nowiki>
 
  
 
  ---~---~---~---~---~---~---~---~---
 
  ---~---~---~---~---~---~---~---~---

Latest revision as of 22:30, 4 December 2025

integer interrupt( flags : integer, dilexp, label )
   Set up interrupt matching message classes matching "flags",
   for example "SFB_COM" or "SFB_COM | SFB_MSG".
   When the program is activated on either of the specified conditions
   the 'dilexp' is evaluated. If true, then execution continues at 'label',
   otherwise the next interrupt is checked (if any).
   Interrupts are saved (restored), when 'recall' is set.
   Returns an integer which is used for clear() to clear an interrupt.
Example:
The following program shows, that the owner (self) of the program keeps
snoring while sleeping. The on_activation ensures that the program
is only activated when the owner is sleeping. However, since the interrupt
precede the on_activation, these may still be intercepted before the
on_activation. The on_activation is just another type of interrupt that
reacts on all flags (without actually setting them so that the program
is activated).
When the program receives the message "relief" the snoring stops briefly.
As used, "relief" may only be set once.
When the program receives the message "cured", the snoring stops completely
(i.e. the program quits itself).

 dilbegin

 var
    i : integer;

 code
dilend
---~---~---~---~---~---~---~---~---

integer interrupt( flags : integer, dilexp, label )
   Set up interrupt matching message classes matching "flags",
   for example "SFB_COM" or "SFB_COM | SFB_MSG".
   When the program is activated on either of the specified conditions
   the 'dilexp' is evaluated. If true, then execution continues at 'label',
   otherwise the next interrupt is checked (if any).
   Interrupts are saved (restored), when 'recall' is set.
   Returns an integer which is used for clear() to clear an interrupt.
Example:
The following program shows, that the owner (self) of the program keeps
snoring while sleeping. The on_activation ensures that the program
is only activated when the owner is sleeping. However, since the interrupt
precede the on_activation, these may still be intercepted before the
on_activation. The on_activation is just another type of interrupt that
reacts on all flags (without actually setting them so that the program
is activated).
When the program receives the message "relief" the snoring stops briefly.
As used, "relief" may only be set once.
When the program receives the message "cured", the snoring stops completely
(i.e. the program quits itself).

 dilbegin

 var
    i : integer;

 code
dilend
---~---~---~---~---~---~---~---~---