|DIAdem 2017 Help|
|DIAdem 2018 Help|
|DIAdem 2019 Help|
|DIAdem 2020 Help|
|DIAdem 2020 SP1 Help|
Integrates a script in another script.
|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.|
Use the name space to distinguish between procedures that have the same names, in different script files.
The following example assumes that the MyFunc function is in the Test.vbs script as well as the MyLib.vbs script. You can use the name space to distinguish between the two functions. In the example, the MyResult variable receives the result of the MyFunc function in the Test.vbs file and the MyOtherResult variable receives the result of the MyFunc function in the MyLib.vbs file.
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.
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.|