Using Director > Writing Scripts with Lingo > Writing Lingo statements > Defining custom messages

 

Defining custom messages

In addition to using built-in message names, you can define your own messages and corresponding handler names. A custom message can call another script, another handler, or the statement's own handler. When the called handler stops executing, the handler that called it resumes.

Director can send a custom message from any location. The message is first available to handlers in the script from which the message was sent. If no handler is found, the message is available to movie scripts.

If more than one movie script contains a handler for the message, the handler in the movie script that has the lowest cast member number is executed.

A custom handler name must meet the following criteria:

It must start with a letter.

It must include alphanumeric characters only (no special characters or punctuation).

It must consist of one word or of several words connected by an underscore—no spaces are allowed.

It must be different from the name of any predefined Lingo element.

Using Lingo keywords for handler names can create confusion. Although it is possible to explicitly replace or extend the functionality of a Lingo element by using it as a handler name, this should be done only in certain advanced situations.

When you have multiple handlers with similar functions, it is useful to give them names that have similar beginnings so they appear together in an alphabetical listing, such as the listing that can be displayed by the Edit > Find > Handler command.