Command: ScriptInclude
- Updated2024-09-12
- 3 minute(s) read
Command: ScriptInclude
Command: ScriptInclude
Integrates a script in another script.
Input Parameters
ScriptFile |
Specifies the name of a script file. |
[ScriptScope] |
Specifies the name space of a script. By default the ScriptCode variable contains an empty text. |
When the ScriptInclude command is called, DIAdem provides the main script with all the global variables, procedures, and functions in the subscript, and initializes the variables. When ScriptInclude is called, you can access these variables, procedures, and functions in the main script. If you specify the script file without a filename extension, DIAdem first searches for the file with the filename extension .vbs and then for the encrypted file with the filename extension .vbc.
Example
If you start the main script Main.vbs, DIAdem uses the ScriptInclude command to register all the procedures and variables in the Function_Library.vbs subscript. You can then access the GetChnName routine and the strChannelName variable from the main script. If you try to start the Function_Library.vbs subscript, an error message informs you that you cannot execute a subscript.
Contents of the Main.vbs file
Option Explicit ' Register all functions and procedures of Function_Library.vbs Call ScriptInclude("Function_Library") ' Calling the function Call GetChnName(1) Call MsgBoxDisp(strChannelName) Call GetChnName(5) Call MsgBoxDisp(strChannelName)
Contents of the Function_Library.vbs file
Option Explicit ' Labelling as subscript Call Subsequence() ' Initialization Dim strChannelName ' Procedure for evaluating a channel name Sub GetChnName(intChannelNo) strChannelName ="<Channel does not exist!>" ' Initialize string If intChannelNo <= GlobUsedCHn Then ' Less then maximum channel number strChannelName = ChnName(intChannelNo) End If End Sub
Note Call the ScriptInclude command only once at the beginning of a script for each script to be included. Do not call the ScriptInclude command in loops. The following table describes when to use the ScriptStart command instead of the ScriptInclude command. If you use the ScriptInclude command instead of the ScriptStart command you can speed up scripts.
|
Related Topics
Command: ScriptStart | Command: ScriptStatement | Command: SubSequence | Variable: ScriptFile | Variable: ScriptScope | Variable: Statement | Variable: SubSequenceText

