Your Ad Here

Including External Scripts

You can include an external script file (.vbs or .js) in another script file. This lets you reuse common routines without the need to paste them into every file. Once you have included a script file as shown below, the routines exist in the global namespace and you can call them in the same way you would call any other routine in the script.

Including External Files Using VBScript

Here’s an example of including external .vbs files using VBScript:

   '-------------------------------------------------------
'-- Include procedure
'-----------------------------------------------------------

Sub Include( cNameScript )
   Set oFS = CreateObject("Scripting.Filesystemobject")
   Set oFile = oFS.OpenTextFile( cNameScript )
   ExecuteGlobal oFile.ReadAll()
   oFile.Close
End Sub

'-- Samples
Include "C:\user\username\Softimage\Scripts\globals.vbs"
Include "C:\user\username\\Softimage\Scripts\utils.vbs"

Including External Files Using JScript

Here’s how to include external .js files using JScript:

   /*-------------------------------------------------------
--- Include procedure
------------------------------------------------------------*/

function include(filnam) {
   var fso = new ActiveXObject('Scripting.FileSystemObject');
   var fil = fso.OpenTextFile(filnam);
   var s = fil.ReadAll();
   fil.Close();
return s;
}

// Samples
eval(include('C:\\user\\username\\Softimage\\Functions1.js'));
eval(include('C:\\user\\username\\Softimage\\Functions2.js'));


SOFTIMAGE|XSI v.6.01     

Return to Softimage XSI Index


Your Ad Here