When a MetaScript executes is just as important as what the script does. Event listeners objectLoaded, elementChanged, editingStarted, and propertiesChanged can be used to improve the performance of your Virtual Ticket or Digital Storage Manager form.
Suppose you need to generate a list of contacts for a customer to be used in several fields on a form. You have prepared a SQL Query which will return this list of contacts. You could place the script into your field but a more efficient method exists, the Global MetaScript window using an event listener.
Before, located in the MetaScript expression window of each field the script is used in:
|RunSQLQuery("select contact_name from your_table");|
After, contained in the Global MetaScript window:
|return RunSQLQuery("select contact_name from your_table");|
While there is some additional scripting needed when using the Global MetaScript area as opposed to the field level, the objectLoaded event listener tells the script to execute only on objectLoaded (form loading), saving numerous other executions of the script. Scripts placed in a field run each time the user tabs in and out of the scripted field.
For more information about Event Listeners, refer to the MetaScript Reference, located at: http://www.meta-comm.com/documentation