Using a message with local scope
Once a message has 'local' scope, it can be accessed by any other clip element in the same test clip. Its values can be used in scripts and to set clip properties. A typical method is to place a script after the scoped message. Such a script will typically refer to the position of the scoped message, do something with the message response, and then clear the response from memory.
For example, in a script placed immediately after the scoped message, you would get the preceding message using this code:
The script doesn't have to be the next item in a test clip. For example, if the message is two prior, use
var msg = $context.currentItem.previousItem;
There are a variety of uses for a given message response (including, but not limited to, the following example scripts:
- Extract data from a message response
- Throw an error if a specified response does not occur
- Capture a message output insert that value into subsequent clip properties. Refer to How do I dynamically or programmatically substitute a value into a Message or Browser Action before ...