11.42 sendevent()

You can send external events in rules to other objects by using the function sendevent(). For mapping serves the EventID parameter, which may be assigned a number as well as any arbitrary value (e.g. a previously defined message resource). On the object given in the Object parameter a respective external event must be defined.

Definition

void sendevent
(
      object   Object  input,
      anyvalue EventID input
  { , anyvalue Arg1    input }
      ...
  { , anyvalue Arg14   input }
)

Parameters

object Object input
Object to which the external event is sent.
anyvalue EventID input
Unique identifier of the event.
anyvalue Arg1 input

anyvalue Arg14 input
Parameters of the external event.

Remarks

When objects, e.g. message resources, are used for the EventID parameter, these objects must not be destroyed before the asynchronous processing of the event. Otherwise the event cannot be mapped anymore.

Furthermore it has to be kept in mind, that the used event (see also chapter “External Events”) requires at most 14 parameters as imposed through the 16 parameter limit of the Rule Language, more parameters cannot be passed by the sendevent() function (the first two parameters are already occupied by the object and the event).

Please avoid any kind of cycles in messages. This may cause endless loops.

Example

dialog ExampleDialog

on dialog start
{
  sendevent(ExampleDialog, 42, "Answer");
}

on dialog extevent 42 (string Question)
{
  print Question;
  exit();
}

See also

Built-in function sendmethod()

C functions DM_QueueExtEvent and DM_SendEvent in manual “C Interface - Functions”