SBM ModScript Reference → Additional SBM ModScript Features → Including Other Scripts
You can use the include("scriptname") function to include scripts within scripts. This enables you to write utility scripts to use repeatedly within multiple scripts. The include("scriptname") function executes like other ModScript functions; the referenced script is not executed until the function call is reached. Use include statements at the top of your script to ensure that functions defined in the included scripts are defined prior to any line in the script that uses those functions.
The following information pertains to the include("scriptname") function:
Include the name of the script as the argument for the include function. 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 function does not exist, the script fails.
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") function is executed; the second include("script A") function is ignored.
It is a good practice to use the include("scriptname") function at the beginning of a main script rather than later in 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).
Also see include().
Copyright © 2007–2018 Serena Software, Inc., a Micro Focus company. All rights reserved.