I found a discussion here
which was initiated by an old and now closed thread here
Although the current version of ooREXX does not support WSH, it is basically possible to call VBscript from REXX.
REXX was designed as a glue language with the ability to send commands to external environments and to further process the results of these commands.
So we only need slightly adjust the given VBScript procedure, so that it takes the command line arguments and outputs the result to stdout:
add_two.vbs
and then we can call it from REXX and get back the result:
rexx_vbscript.rex
I tried it with ooREXX and Regina and it works:
In the example above I took advantage of RXQUEUE.
Another possibility would be to redirect the output of VBscript into temporary file and then read the result from it.
which was initiated by an old and now closed thread here
Although the current version of ooREXX does not support WSH, it is basically possible to call VBscript from REXX.
REXX was designed as a glue language with the ability to send commands to external environments and to further process the results of these commands.
So we only need slightly adjust the given VBScript procedure, so that it takes the command line arguments and outputs the result to stdout:
add_two.vbs
Code:
[COLOR=#0000ff]'----- main -------[/color]
[COLOR=#0000ff]' get argumnets[/color]
a [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]cdbl[/color][COLOR=#804040][b]([/b][/color]WScript[COLOR=#804040][b].[/b][/color]Arguments[COLOR=#804040][b].[/b][/color][COLOR=#a020f0]Item[/color][COLOR=#804040][b]([/b][/color][COLOR=#ff00ff]0[/color][COLOR=#804040][b]))[/b][/color]
b [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]cdbl[/color][COLOR=#804040][b]([/b][/color]WScript[COLOR=#804040][b].[/b][/color]Arguments[COLOR=#804040][b].[/b][/color][COLOR=#a020f0]Item[/color][COLOR=#804040][b]([/b][/color][COLOR=#ff00ff]1[/color][COLOR=#804040][b]))[/b][/color]
[COLOR=#0000ff]' compute result [/color]
c [COLOR=#804040][b]=[/b][/color] add_two[COLOR=#804040][b]([/b][/color]a[COLOR=#804040][b],[/b][/color] b[COLOR=#804040][b])[/b][/color]
str_line [COLOR=#804040][b]=[/b][/color] a [COLOR=#804040][b]&[/b][/color] [COLOR=#ff00ff]" + "[/color] [COLOR=#804040][b]&[/b][/color] b [COLOR=#804040][b]&[/b][/color] [COLOR=#ff00ff]" = "[/color] [COLOR=#804040][b]&[/b][/color] c
WScript[COLOR=#804040][b].[/b][/color]StdOut[COLOR=#804040][b].[/b][/color][COLOR=#a020f0]writeline[/color] str_line
[COLOR=#0000ff]'------functions --------[/color]
[COLOR=#804040][b]function[/b][/color] add_two[COLOR=#804040][b]([/b][/color]x[COLOR=#804040][b],[/b][/color] y[COLOR=#804040][b])[/b][/color]
add_two [COLOR=#804040][b]=[/b][/color] x [COLOR=#804040][b]+[/b][/color] y
[COLOR=#804040][b]end[/b][/color] [COLOR=#804040][b]function[/b][/color]
and then we can call it from REXX and get back the result:
rexx_vbscript.rex
Code:
[COLOR=#0000ff]/*---------- Calling VBscript from REXX --------------------*/[/color]
[COLOR=#0000ff]/*** Main program ***/[/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"Enter variables to add:"[/color]
x [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]raw_input([/color][COLOR=#ff00ff]"x = "[/color][COLOR=#008080])[/color]
y [COLOR=#804040][b]=[/b][/color] [COLOR=#008080]raw_input([/color][COLOR=#ff00ff]"y = "[/color][COLOR=#008080])[/color]
[COLOR=#0000ff]-- create command[/color]
cmd [COLOR=#804040][b]=[/b][/color] [COLOR=#ff00ff]"cscript /NoLogo add_two.vbs "[/color][COLOR=#804040][b]||[/b][/color]x[COLOR=#804040][b]||[/b][/color][COLOR=#ff00ff]" "[/color][COLOR=#804040][b]||[/b][/color]y[COLOR=#804040][b]||[/b][/color][COLOR=#ff00ff]" | rxqueue"[/color]
[COLOR=#0000ff]-- execute command[/color]
cmd
[COLOR=#0000ff]-- get result from RXQUEUE[/color]
[COLOR=#804040][b]if[/b][/color] [COLOR=#008080]queued()[/color] [COLOR=#804040][b]then[/b][/color]
[COLOR=#804040][b]parse pull[/b][/color] a [COLOR=#ff00ff]" + "[/color] b [COLOR=#ff00ff]" = "[/color] z
[COLOR=#804040][b]else[/b][/color]
[COLOR=#804040][b]say[/b][/color] [COLOR=#ff00ff]"Error executing command !"[/color]
[COLOR=#0000ff]--[/color]
[COLOR=#804040][b]say[/b][/color] x [COLOR=#ff00ff]"+"[/color] y [COLOR=#ff00ff]"="[/color] z
[COLOR=#804040][b]exit[/b][/color]
[COLOR=#0000ff]/**************** Functions ****************/[/color]
[COLOR=#008080]raw_input[/color][COLOR=#804040][b]:[/b][/color] [COLOR=#804040][b]procedure[/b][/color]
[COLOR=#804040][b]parse arg[/b][/color] prompt
[COLOR=#804040][b]call [/b][/color][COLOR=#008080]charout[/color] [COLOR=#804040][b],[/b][/color] prompt
[COLOR=#804040][b]parse pull[/b][/color] inp
[COLOR=#804040][b]return[/b][/color] inp
I tried it with ooREXX and Regina and it works:
Code:
C:\Work>rexx rexx_vbscript.rex
Enter variables to add:
x = 5
y = 15
5 + 15 = 20
In the example above I took advantage of RXQUEUE.
Another possibility would be to redirect the output of VBscript into temporary file and then read the result from it.