Manual:DIL Manual/sendto()
Jump to navigation
Jump to search
sendto()
Procedure. Sends a message to the DIL programs on one unit.
sendto(msg : string, u : unitptr)
Every DIL program on u that is waiting for SFB_MSG (in a wait() or an interrupt()) gets the message. The receivers run at once, before sendto() returns. In each of them argument is the message and activator is the sender's unit; medium and target are null.
The unit can be anywhere in the game. Only the programs on u itself get the message, not those on what it contains.
Parameters
| Name | Type | Meaning |
|---|---|---|
| msg | string | The message. Receivers usually compare it with argument.
|
| u | unitptr | The unit whose programs get it. |
Notes
sendto(msg, self)reaches the other programs on the sender's own unit, aware or not. The sending program itself never gets its own message.- A program that isn't waiting for
SFB_MSGat that moment misses the message; it isn't kept for later. - The programs on
uget it in fnpri order. One that does block or holds priority keeps it from the ones after it. - Nothing happens when
uor the message is null. - Afterwards the sender's secures are tested: if a receiver moved a secured unit away, the sender goes to that secure's label.
Example
dilbegin call_captain();
var
capt : unitptr;
code
{
heartbeat := PULSE_SEC * 30;
:start:
wait(SFB_COM, TRUE);
capt := findsymbolic("captain@ex");
if (capt != null)
sendto("alarm " + self.outside.name, capt);
pause;
goto start;
}
dilend
dilbegin captain();
code
{
:start:
wait(SFB_MSG, "alarm" in argument);
exec("shout To arms! " + activator.name + " needs help!", self);
goto start;
}
dilend
A guard in a fight calls the captain, wherever the captain is, at most every 30 seconds. In haon_dor.zon the orc chief tells Mary she has lost her pot with sendto("gotit", u1).