Home | OS/2 Software | Rexx | Passing data values using the REXX queue (Intermediate)

Passing data values using the REXX queue (Intermediate)

Contributed by: H. C. Motin

You can use the REXX QUEUE facility to pass variable data between VisProREXX and any other REXX program. For example, suppose you want to use a VisProREXX program as the graphical front end to a Mesa 2 spreadsheet script. That is, you want to select input data values, using the VisProREXX interface, and then pass those values to your Mesa 2 script (these scripts are written in REXX). Suppose this should all work after you start the script. In this scenario passing variable data using the CALL, ARG and RETURN instructions may not work (especially if you have many variables). Instead, you can and should use a REXX queue. The main steps of this process are as follows:

  1. Create a named queue in your script and make it the active queue. This process includes a call to an internal subroutine within the script.
  2. CALL the VisProREXX program from within the Mesa 2 script.
  3. Make your data selections, using the controls that you created in your VisProREXX program.
  4. Click the "OK Button" on your VisProREXX main form. That places your selected data values in the active queue, closes the VisProREXX program and returns you to the script.
  5. Retrieve the data values from the active queue, using the PARSE PULL instruction. Close the queue and then continue the script to its end.

Instead of using the REXX QUEUE instruction, you could use the PUSH instruction. The QUEUE instruction places data in a queue, using a "first in first out" (FIFO) order. The PUSH instruction places it in, using a "last in first out" (LIFO) order. If you use PUSH, you then must reverse the order of all your PARSE PULL instructions to retrieve the data from the queue in the correct order.

In order for all this to work you must place a copy of the *.dll file for your VisProREXX program in a directory contained in your LIBPATH statement in your CONFIG.SYS file. "The REXX Cookbook" by Merrill Callaway and "Mastering OS/2 REXX" by Gabriel F. Gargiulo are 2 excellent reference sources for doing all of the above.

Below, is an example of the required REXX code for the five itemized steps, which are described above:


 

 


    /*Begin REXX code in the Mesa 2 script to complete steps 1 and 2, described above*/
/*Begin creating the REXX queue named FUNDSINPUT and making it the active queue*/
NewQueue = RXQUEUE("CREATE","FUNDSINPUT")
CALL QUEUECHECK
Mesa2Queue = RXQUEUE("SET",NewQueue)    /*Make "FUNDSINPUT" the active queue*/
                    /*NewQueue = "FUNDSINPUT" because of the CALL to QUEUECHECK*/
/*End creating the REXX queue named FUNDSINPUT and making it the active queue*/


/*Begin calling the VisProREXX program, FUNDS.CMD, to provide fund financial input data to the script*/
CALL "D:\MESA2\SUBROUTINES\FUNDS\FUNDS.CMD"    /*The complete path name to the VisProREXX program*/
/*End calling the VisProREXX program, FUNDS.CMD, to provide fund financial input data to the script*/


/*Begin the subroutine to check whether or not "FUNDSINPUT" is the active queue*/
/*If "FUNDSINPUT" is not the active queue, delete the active queue and set NewQueue = "FUNDSINPUT"*/
QUEUECHECK:            /*Subroutine label*/
IF NewQueue = "FUNDSINPUT" THEN
    SIGNAL FINISHSUB
ELSE DO
    d = RXQUEUE("DELETE",NewQueue)
    NewQueue = "FUNDSINPUT"
END
FINISHSUB:
RETURN
/*End the subroutine to check whether or not "FUNDSINPUT" is the active queue*/
    /*End REXX code in the Mesa 2 script to complete steps 1 and 2, described above*/

    /*Begin REXX code in the VisProREXX program to complete step 4, described above*/
PLACEINQUEUE:
NewQueue = "FUNDSINPUT"
ActiveQueue = RXQUEUE("SET",NewQueue)    /*Make "FUNDSINPUT" the active queue in VisProREXX*/
QUEUE Date    /*Place the value of the "Date" variable in the queue in FIFO order*/
QUEUE Fund1UnitPrice    /*Place the value of the "Fund1UnitPrice" variable in the queue in FIFO order*/
QUEUE Fund2UnitPrice    /*Place the value of "Fund2UnitPrice" in the queue in FIFO order*/
QUEUE Fund3UnitPrice    /*Place the value of "Fund3UnitPrice" in the queue in FIFO order*/
QUEUE ..., etc.    /*Place the value of the this variable in the queue in FIFO order*/
    /*End REXX code in the VisProREXX program to complete step 4, described above*/

    /*Begin REXX code in the Mesa 2 script to complete step 5, described above*/
/*Begin retrieving the input financial data from the REXX queue and then closing (deleting) the queue*/
PARSE PULL Date        /*Retrieve the value of the "Date" variable from the queue*/
PARSE PULL Fund1UnitPrice    /*Retrieve the value of "Fund1UnitPrice" from the queue*/
PARSE PULL Fund2UnitPrice    /*Retrieve the value of "Fund2UnitPrice" from the queue*/
PARSE PULL Fund3UnitPrice    /*Retrieve the value of "Fund3UnitPrice" from the queue*/
PARSE PULL ..., etc.        /*Retrieve the value of this variable from the queue*/

d = RXQUEUE("DELETE","FUNDSINPUT")    /*Delete the queue*/
/*End retrieving the input financial data from the REXX queue and then closing (deleting) the queue*/
    /*End REXX code in the Mesa 2 script to complete step 5, described above*/