Running Other Scripts and Handlers
Writing other scripts and handlers outside of the main script for your test allows you to create reusable chunks of code, effectively modularizing your test. But, how do you call those scripts and handlers once they're written? This page explains how, and then provides some related commands and functions.
Calling a Local Handler or Script
Calling a Handler or Script as a Command
Syntax:
scriptOrHandlerName {parameters}
To call another handler within your script, simply use the handler name as a command, along with any needed parameters. For example, consider this command:
recordScores 2017, rawScores
If there is a "to" (or "on") handler in the local script for the recordScores message, this command will run that handler, passing it two parameters.
If there is no local handler for the recordScores command, but there is a script by that name, that script (meaning, the script's initial handler) will be run, passing it the two parameters. So in either case, to call a handler in the local script, or another script in the same directory, all that is needed is to use that handler or script name as a command.
Calling a Handler or Script as a Function
Syntax:
scriptOrFunctionName ( {parameters} )
Calling a script or handler as a function works the same way: just use the script or handler name as a function name within an expression context (not at the beginning of a line, which would be a command call). For example, consider this function call:
put consolidatedSales("Ohio") into ohioSales