REXX Tips & Tricks, Version 2.80


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Using queues for IPC



The default queue SESSION is a unique queue for each OS/2 session. So, if 
you want to use a queue to communicate between two or more sessions you 
must use a private queue. 
Example: 

 
/* use a private queue for IPC                                        */

                        /* name of the private queue                  */
  privatQueue = "MYQUEUE"                                    /* v1.70 */

                        /* get the name of the current active queue   */
  oldQueue = rxQueue( "GET" )

  if oldQueue <> privatQueue then
  do
                        /* try to create the private queue            */
    newQueue = rxQueue( "CREATE", privatQueue )
    if newQueue <> privatQueue then
    do
                        /* the queue already exist -> delete the just */
                        /* created queue!                             */
      call rxQueue "DELETE", newQueue )
    end /* if rxQueue( "Create", ... ) */

                        /* make our private queue the active queue    */
    call rxQueue "SET", privatQeueue
  end /* if oldQueue <> privatQueue then */
  else
  do
                    /* the private queue is already the active queue  */
                    /* do not reset the active queue at program end   */
    oldQueue = ""
  end /* else */

  /* ... do something */


ProgramEnd:
  if oldQueue <> "" then
  do
                        /* flush the private queue                    */
    do while queued() <> 0
      call lineIN "QUEUE:"
    end /* do until queued() <> 0 */

                        /* reset the original queue                   */
    call rxQueue "SET", oldQueue

                        /* delete the private queue                   */
    call rxQueue "DELETE", privatQueue
  end /* if oldQueue <> "" then */

exit 0

  

Inf-HTML End Run - Successful