Product SiteDocumentation Site

18.3.2. The RXQUEUE Filter


>>-RXQUEUE--+-----------+--+--------+--------------------------><
            +-queuename-+  +-/FIFO--+
                           +-/LIFO--+
                           +-/CLEAR-+

The RXQUEUE filter usually operates on the default queue named SESSION. However, if an environment variable named RXQUEUE exists, the RXQUEUE value is used for the queue name.
For a full description of Rexx queue services for applications programming, see Section 14.1.3, “External Data Queue”.
Parameters:
queuename/LIFO
stacks items from STDIN last in, first out (LIFO) on a Rexx queue.
queuename/FIFO
queues items from STDIN first in, first out (FIFO) on a Rexx queue.
queuename/CLEAR
removes all lines from a Rexx queue.
RXQUEUE takes output lines from another program and places them on a Rexx queue. There is currently a limit of 65472 characters for a single line. If a line contains more characters than the limit, those characters are discarded.
A Rexx procedure can use RXQUEUE to capture operating system command and program output for processing. RXQUEUE can direct output to any Rexx queue, either FIFO (first in, first out) or LIFO (last in, first out).
RXQUEUE uses the environment variable RXQUEUE for the default queue name. When RXQUEUE does not have a value, RXQUEUE uses SESSION for the queue name.
The following example obtains the Windows version number with RXQUEUE:

Example 18.2. Command RXQUEUE

/* Sample program to show simple use of RXQUEUE */
/* Find out the Windows version number, using the  */
/* VER command.  VER produces two lines of      */
/* output; one blank line, and one line with the*/
/* format "The Windows Version is n.nn"            */

"VER |RXQUEUE"         /* Put the data on the Queue      */
pull .                 /* Get and discard the blank line */
Pull . "VERSION" number "]" /* The bracket is required for
Windows 95, not for Windows NT */
Say "We are running on Windows Version" number

Note that the syntax of the version string that is returned by Windows can vary, so the parsing syntax for retrieving the version number may be different.
The following example processes output from the DIR command:

Example 18.3. Command RXQUEUE

/* Sample program to show how to use the RXQUEUE filter */
/* This program filters the output from a DIR command,  */
/* ignoring small files.  It displays a list of the     */
/* large files, and the total of the sizes of the large */
/* files.                                               */

size_limit = 10000            /* The dividing line      */
/* between large and small*/
size_total = 0                /* Sum of large file sizes*/
NUMERIC DIGITS 12             /* Set up to handle very  */
/* large numbers          */

/* Create a new queue so that this program cannot       */
/* interfere with data placed on the queue by another   */
/* program.                                             */

queue_name = rxqueue("Create")
Call rxqueue "Set", queue_name

"DIR /N | RXQUEUE" queue_name

/* DIR output starts with five header lines             */
Do 5
Pull .                     /* discard header line    */
End

/* Now all the lines are file or directory lines,       */
/* except for one at the end.                           */

Do queued() - 1               /* loop for lines we want */
Parse Pull . . size . name ./* get one name and size */
/* If the size field says "<DIR>", we ignore this    */
/* line.                                             */
If size <> "<DIR>" Then
/* Now check size, and display                    */
If size > size_limit Then Do
Say format(size,12) name
size_total = size_total + size
End
End

Say "The total size of those files is" size_total

/* Now we are done with the queue.  We delete it, which */
/* discards the line remaining in it.                   */

Call rxqueue "DELETE", queue_name