Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
The event-sending statement looks like:
expression -> name ( arg1, arg2, ... )
expr1 -> [ expr2 ] ( arg1, arg2, ... )The expression (or expr1) must resolve to one agent. (See § 7.5.1, page 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 = expressionanalogous to the syntax of a function call (See Chapter 6, page ). If only one argument is specified and the first form is used 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 , and uses that as the event value. (See Chapter 7, page , for a full discussion.)
If an event is sent in the context of an expression, the interpreter waits for a result from the client. When this result is received the evaluation of the expression is 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 case because a result is needed the interpreter waits. (See § 4.12, page .)
There are two types of statements for receiving events, whenever and await. Both are discussed in full in § 7.5, page , and § 7.6, page ; here is a brief overview of the related syntax.
A whenever statement looks like:
whenever event1, event2, ... do statementAt least one event must be specified. When any of the given events are 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. (See § 7.5.1, page , for a description of event syntax.)
await statements have three forms:
await event1, event2, ...
await only event1, event2, ...
await only event1, event2, ... except event1, event2, ...The first form waits for any one of the specified event's to be received before proceeding with execution. If other events arrive during the interim, they are processed normally. The second form does not process interim events but instead drops them with a warning. The third form only processes those interim events listed after the except keyword.
After completion of any await, the variables $agent, $name, and $value correspond to the event that caused the await to complete. (See § 7.6, page , for a full description.)
The activate and deactivate statements provide a mechanism for turning whenever statements ``on'' and ``off''.
These statements have the following forms:
activate
deactivate
activate expr
deactivate expr
The builtin function whenever_active() is used to see if a whenever statement is active or not. (See § 10.9, page , for information about whenever_active(), and § 7.5.4, page , for information about activate and deactivate.)
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.
These statements have the following form:
link event1 to event2
unlink event1 to event2
(See § 7.7, page , for a full description.)