Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


REXX & VB - part II

REXX & VB - part II

REXX & VB - part II

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:


'----- main -------
' get argumnets
a = cdbl(WScript.Arguments.Item(0))
b = cdbl(WScript.Arguments.Item(1))
' compute result 
c = add_two(a, b)
str_line = a & " + " & b & " = " & c
WScript.StdOut.writeline str_line

'------functions --------
function add_two(x, y) 
  add_two = x + y
end function 

and then we can call it from REXX and get back the result:


/*---------- Calling VBscript from REXX --------------------*/
/*** Main program ***/
say "Enter variables to add:"
x = raw_input("x = ")
y = raw_input("y = ")

-- create command
cmd = "cscript /NoLogo add_two.vbs "||x||" "||y||" | rxqueue"
-- execute command
-- get result from RXQUEUE
if queued() then
  parse pull a " + " b " = " z
  say "Error executing command !"
say x "+" y "=" z

/**************** Functions ****************/
raw_input: procedure
  parse arg prompt
  call charout , prompt
  parse pull inp
  return inp 

I tried it with ooREXX and Regina and it works:


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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close