I want to include a VBscript into another VBscript (kinda simulating OO in VBS), found something online and it seems Ok to me. I keep getting an "expected statement"-error on the ExecuteGlobal
line:
Dim scriptLocation
Sub Main
scriptLocation ="script2.vbs"
Include(scriptLocation)
End Sub
Sub Include (strFile)
Dim fsObj : Set fsObj = CreateObject("Scripting.FileSystemObject")
Dim vbsFile : Set vbsFile = fsObj.OpenTextFile(strFile, 1, False)
Dim myFunctionsStr : myFunctionsStr = vbsFile.ReadAll
vbsFile.Close
Set vbsFile = Nothing
Set fsObj = Nothing
ExecuteGlobal myFunctionsStr
End Sub
Anyone any idea?
myFunctionsStr
before you callExecuteGlobal
? Have you tried with something like aHelloWorld()
function to check that the code is working in principle? Also the above is most definitely not your entire code, as it wouldn't do anything at all. – Ansgar WiechersstrFunctionsStr
is after the file was read. Add a lineWScript.Echo strFunctionsStr
before theExecuteGlobal
instruction. – Ansgar Wiechers