Syntax:
on message {block} on event {block} on exit {module} {block} on {socket} {block}
Keyword handler:
linguist.basic.keyword.BKOn.class
Runtime handler(s):
linguist.basic.handler.BHOn.class linguist.basic.handler.LHStop.class
Function:
The first form handles a message from another running script module (see send). If the recipient is idle the message will be executed immediately, otherwise the system will wait for the current thread to stop, then deal with the message. For this (and other) reasons, threads should be kept as short as possible, avoiding lengthy loops.
The second form deals with events sent from outside Linguist. What happens next is usually covered by extra keywords in a custom additional package.
The third form allows you to specify some processing that must be done before the script quits.
The last form allows you to specify a handler to take control when a message is received from a port. The cause of the callback is available to the code that immediately follows the on instruction, by using the name of the socket as a String value.
Example(s):
on message prompt the message on message begin if the sender is "Main" gosub to ProcessMessage end on event go to ProcessEvent on exit Intro run "Main"