If you want to break your script file into smaller files, you can use these techniques to "include" the sub-files.
Thanks to Krenath, Magnum and Rire for contributing ...
VBscript
Jscript
Thanks to Krenath, Magnum and Rire for contributing ...
VBscript
Function GetFileContents(sFileName)
Dim FSO, ScriptFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ScriptFile = FSO.OpenTextFile(sFilename,1)
GetFileContents = ScriptFile.ReadAll
Set ScriptFile = Nothing
Set FSO = Nothing
End Function
World.Note "Include Script File: IncludeA.vbs"
ExecuteGlobal GetFileContents("C:\mushclient\includea.vbs")
World.Note "Include Script File: IncludeB.vbs"
ExecuteGlobal GetFileContents("C:\mushclient\includeb.vbs")
Jscript
// ----------------------------------------
var FileScriptingObject = new ActiveXObject("Scripting.FileSystemObject");
function Include( FileName ) {
var File = FileScriptingObject.OpenTextFile( FileName, 1 );
var Code = File.ReadAll();
File.Close();
return( Code );
}
// YOU CANNOT EXECUTE THIS STATEMENT FROM INSIDE OF ANY
// BLOCK OR OTHER SCOPE. IF YOU DO, THE INCLUDED FILE
// WILL ONLY APPLY TO THAT SCOPE.
World.Note ("Include Script File: IncludeA.js");
eval( Include( "c:\mushclient\includea.js" ) );
World.Note ("Include Script File: IncludeB.js");
eval( Include( "c:\mushclient\includeb.js" ) );