INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!

*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.

Jobs

REXX & VB - part II

REXX & VB - part II

(OP)
I found a discussion here
http://rexx-language-association-forum.44760.x6.na...
which was initiated by an old and now closed thread here
http://www.tek-tips.com/viewthread.cfm?qid=1663499

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

'----- 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:
rexx_vbscript.rex

CODE

/*---------- 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
cmd
-- get result from RXQUEUE
if queued() then
  parse pull a " + " b " = " z
else
  say "Error executing command !"
--
say x "+" y "=" z
exit

/**************** 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:

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.

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!

Resources

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