SBM ModScript Reference → Additional SBM ModScript Features → Including Other Scripts
You can use the include(scriptname) tag to include scripts within scripts. This enables you to write utility scripts to use repeatedly within multiple scripts. When the include(scriptname) tag is found within a script, SBM fully expands the included script, parses the combined text, and then executes the script.
The following information pertains to the include(scriptname) tag:
Include the name of the script as the argument for the include tag. The script name should be identical to the name provided when adding or editing a script in SBM Composer. The script name is case sensitive; it must match the name of the script with respect to the proper case.
If the script used in the include tag does not exist, the script fails.
You can not use include(scriptName) in multi-line comments—the include will insert the included script rather than ignoring the include directive.
Using include(scriptname) maintains line numbers in error messages, and also, if an error occurs in the code from the included script, the call stack of the error message provides the included script's name.
You can only include a script once within a script. For example, if your main script includes include(script A) twice, the first include(script A) tag is expanded and executed; the second include(script A) tag is replaced by a blank line.
The main script must be associated with an SBM context, but scripts called by the include tag should not be invoked separately within SBM.
It is a good practice to use the include(scriptname) tag at the beginning of a main script and not within the main script. Functions defined in included scripts will not exist in the current runtime until the include is processed (however, if the included script includes logic that is not encapsulated in a function definition, that include should be placed in the location of the script where that logic should be executed.
Copyright © 2007–2017 Serena Software, Inc. All rights reserved.