Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Well, it all said in the header.
I have an application with a lot of macros in VBScript. We want to add functionality that is easy to write in JScript. Apparently we can't mix... But maybe I"m wrong and it is possible (?)
Thank you,
Michael
Got me thinking, but the best I can come up with is to use a .wsf file like in this blog ...
http://blogs.msdn.com/b/gstemp/archive/2004/02/24/79183.aspx
So your macro code (in VBScript) would be something like ...
Function Wrapper(param1)
Set objShell = CreateObject("WScript.Shell")
objShell.run("cscript C:\code.wsf //job:job2 //job:job1")
end function
sub CallWrapper
Wrapper(dummyParam)
end sub
The test file code.wsf contains ...
<?xml version="1.0" ?>
<package>
<job id="Job1">
<script language="VBScript">
MsgBox "Hello, I'm VBScript code."
</script>
</job>
<job id="Job2">
<script language="JScript">
WScript.Echo("Hello, I'm JScript code.");
</script>
</job>
</package>
I'm sure it will have limitations though!
flipside
Thank you flipside, I'll certainly give it a try!
I've been doing some more investigation and MSScriptControl might be the solution to this, a simple example being ...
function f_runJS
set O = CreateObject("MSScriptControl.ScriptControl")
O.Language= "JScript"
O.AddCode "function x(a,b) {return 'the answer is:' +(a+b);}"
f_runJS = O.Run ("x",1,2)
end function
You may need to register msscript.ocx (System32 folder) using regsrvr32 to get it working, and it's only 32-bit.
flipside