Aladdin420
Programmer
Dim objSC, blah, sCCSserver, sMachine, Copier, oFSo, x, y
Set oFSo = CreateObject("Scripting.FileSystemObject"
Set objSC = CreateObject("MSScriptControl.ScriptControl"
Set oShell = CreateObject("Wscript.Shell"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
objSC.Language = "VBScript"
I wanted to call a Sub procedure located on a seperate script using the .Run method. I have written the code, but there are a few bugs. Here is the code:
1) In this first function I tried to pass only parameters to the script containing the Sub procedure.
blah1 = "Function Load(x, y)"& vbNewLine
blah1 = blah1 & "Load = ""c:\project\vbs.stuff\test207.vbs "" & x & "" "" & y"
blah1 = blah1 & vbNewLine & "End Function"
objSC.AddCode blah1
x = "2"
y = "3"
oShell.Run(objSC.Run("Load", "2", "3")
Now the line above line calls the "test207.vbs" script, here's test207.vbs :
Sub Addxy(x, y)
Wscript.Echo "x is:", x
Wscript.Echo "y is:", y
Total = x + y
End Sub
Dim Total
Wscript.Echo Total
This test207 script is called, but the parameters "2" and "3" from the main script aren't brought with the call.
And so both x and y are equal to zero.
'**************
The second time I tried to call the Sub procedure directly from my main script:
2)
blah1 = "Function Load(Addxy)"& vbNewLine
blah1 = blah1 & "Load = ""c:\project\vbs.stuff\test207.vbs "" & Addxy(x, y)"
blah1 = blah1 & vbNewLine & "End Function"
objSC.AddCode blah1
oShell.Run(objSC.Run("Load", "Addxy(2, 3)")
This gives an error of a mismatch 'Addxy'.
Got any ideas , I'm all ears.
Thanks
Aladdin420