TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Ruud Senden
from: David Noon
date: 1996-01-05 21:43:12
subject: Capturing output

On Wednesday, 96/01/03, Ruud Senden wrote to All about "Capturing
output" as follows:

RS> I am (still) writing a REXX-program, for which it would be 
RS> nice if I could capture the output of OS/2-programs which I 
RS> run from the REXX-script. I could use this to examine the 
RS> output of the program, or to write the output of the 
RS> program to both the screen and a logfile.

Hi Ruud,

I think RXQUEUE() might be just the ticket here. There is a RXQUEUE()
built-in function of REXX to clear and read queues, and a RXQUEUE
command that can capture output from other programs and queue it to a
REXX exec.

For example:

  /* REXX */
    .
    .
  /* Create a new queue */
  My_queue = RXQUEUE('CREATE')

  /* Make new queue the active one,
     and save the previous queue */
  Old_queue = RXQUEUE('SET',My_queue)

  /* Start the other program in a hidden session
     and pipe its output to RXQUEUE */
  ADDRESS 'CMD' 'DETACH Other_prog.EXE | RXQUEUE'

  DO WHILE LINES('QUEUE:') > 0
    /* Retrieve a line of output from our program */
    Pgm_output_line = RXQUEUE('GET',My_queue)
    /* Manipulate the output line */
      .
      .
  END

  /* We are finished with this queue */
  CALL RXQUEUE 'DELETE',My_queue

  /* If there was an earlier queue, re-establish it */
  IF Old_queue \== '' THEN
       CALL RXQUEUE 'SET',Old_queue

Please note that I typed this code directly into my mail reader as a
schematic outline, so it has not been tested. It should not be taken
as an alternative to reading the documentation.

Since you seem to be doing a lot of REXX coding, you might care to
join us in the OS2REXX echo.

Regards

Dave


 * KWQ/2 1.2i * NO CARRIER...just 2 destroyers and a minesweeper.
--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 808 809 934 955 712/407 515
SEEN-BY: 712/517 628 713/888 800/1 7877/2809
@PATH: 440/4 141/209 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.