next up previous contents index
Next: Leaving Out the Statement Up: Statements Previous: local ``Statement''

Sending and Receiving Events

Sending and receiving events forms the heart of Glish, and both are discussed in Chapter 7, page gif. Here we briefly cover the syntax of the related statements.

Sending Events

 

  The event-sending statement looks like:

expression -> name ( argtex2html_wrap_inline15496, argtex2html_wrap_inline15498, tex2html_wrap_inline15512 )

exprtex2html_wrap_inline15496 -> [ exprtex2html_wrap_inline15498 ] ( argtex2html_wrap_inline15496, argtex2html_wrap_inline15498, tex2html_wrap_inline15512 )

The expression (or exprtex2html_wrap_inline15496) must resolve to one agent; see § 7.5.1, page gif, for more information. Each   arg argument (there needn't be any, in which case an event with the value F is sent) has one of two forms:
expression

name = expression

in a manner directly analogous to the syntax of a function call (Chapter 6, page gif). If only one argument and the first form is used specified then Glish evaluates expression and uses the result as the event value. If more than one argument is specified or the second form used for a lone argument then Glish constructs a record in a manner similar to that described in § 3.4.1, page gif, and uses that as the event value. Again, see Chapter 7, page gif, for a full discussion.

If an event is sent in the context of an expression, then the interpreter waits for a result from the client so that the evaluation of the expression can be completed. The syntax is the same, but the context is different:

    my_agent->reset()
    if ( my_agent->ready() ) print "agent is configured"
In the first case, no result is required, but in the second, a result is needed so the interpreter waits (see § 4.11, page gif).  

Receiving Events

  There are two types of statements for receiving events, whenever and await. Both are discussed in full in § 7.5, page gif, and § 7.6, page gif; here we just give an overview of the related syntax.

Whenever Statements

 

  A whenever statement looks like:

whenever eventtex2html_wrap_inline15496, eventtex2html_wrap_inline15498, tex2html_wrap_inline15512 do statement
§ 7.5.1, page gif, describes the event syntax. At least one event must be specified. The meaning of the statement is that whenever any of the given events is generated, execute statement with $agent, $name, and $value equal to the agent that generated the event, the name of the event, and the event's value.

Await Statements

 

  await statements have three forms:

await eventtex2html_wrap_inline15496, eventtex2html_wrap_inline15498, tex2html_wrap_inline15512

await only eventtex2html_wrap_inline15496, eventtex2html_wrap_inline15498, tex2html_wrap_inline15512

await only eventtex2html_wrap_inline15496, eventtex2html_wrap_inline15498, tex2html_wrap_inline15512 except eventtex2html_wrap_inline15496, eventtex2html_wrap_inline15498, tex2html_wrap_inline15512

The first form waits for one of the specified event's to be generated (there must be at least one) before proceeding with execution. If other events arrive during the interim they are processed normally. The second form does not process such interim events but instead drops them with a warning. The third form only processes those interim events listed after the except keyword.

After each style of await, $agent, $name, and $value correspond to the event that caused the await to finish.

See § 7.6, page gif, for a full description.  

activate and deactive Statements

    The activate and deactivate statements provide a mechanism for turning whenever statements ``on'' and ``off''.

The statements have the following form:

activate

deactivate

activate expr

deactivate expr

The builtin function whenever_active() can be use to see if a whenever statement is active or not (See § 9.10, page gif). For more information about, activate and deactivate see § 7.5.4, page gif.

link and unlink Statements

    The link and unlink statements provide a mechanism for establishing and suspending point-to-point connections between Glish clients. These connections sacrifice flexibility (being able to inspect and modify event values) for performance.

The statements have the following form:

link eventtex2html_wrap_inline15496 to eventtex2html_wrap_inline15498

unlink eventtex2html_wrap_inline15496 to eventtex2html_wrap_inline15498

See § 7.7, page gif, for a full description.


next up previous contents index
Next: Leaving Out the Statement Up: Statements Previous: local ``Statement''

Thu Nov 13 16:44:05 EST 1997