home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxhll.zip / MSGQUE.REX < prev    next >
OS/2 REXX Batch file  |  1993-12-27  |  2KB  |  99 lines

  1. /* #include <msgque.rex> */
  2.  
  3. QueCreate: procedure expose MsgQ.
  4.    /**
  5.    ***  This will create the REXX queues for the interprocess communications
  6.    ***  with the front-end code.
  7.    **/
  8.  
  9.    arg server_, client_, sleep_
  10.  
  11.    if server_ = '' then
  12.       return 16
  13.  
  14.    if client_ = '' then
  15.       return 16
  16.  
  17.    /* Establish the defaults */
  18.  
  19.    if sleep_ = '' then
  20.       sleep_ = 1
  21.  
  22.    MsgQ.        = ''
  23.    MsgQ.Server  = server_        /* Name of the server rexx queue */
  24.    MsgQ.Client  = client_        /* Name of the client rexx queue */
  25.    MsgQ.Sleep   = sleep_         /* Number of seconds to sleep before next poll */
  26.  
  27.    code = RxQueue('Create',MsgQ.Client)
  28.    code = RxQueue('Create',MsgQ.Server)
  29.  
  30.    /* Make sure there is no garbage in the queues */
  31.  
  32.    code = RxQueue('Set',MsgQ.Client)
  33.    do i = 1 to queued()
  34.       pull .
  35.    end
  36.    MsgQ.Original  = RxQueue('Set',MsgQ.Server)
  37.    do i = 1 to queued()
  38.       pull .
  39.    end
  40.    return 0
  41.  
  42.  
  43. QueProcess: procedure expose MsgQ. State.
  44.    /**
  45.    ***  This will handle the message queue processing
  46.    **/
  47.  
  48.    Count = 1
  49.    say 'Waiting for first message...'
  50.    Quit = 'NO'
  51.    do while Quit = 'NO'
  52.       request = linein("QUEUE:")
  53.       parse var request msg param
  54.       call charout ,"Processing #"left(Count,7) left(msg,20,'.')
  55.       Count = Count + 1
  56.       call Methods msg param
  57.       say "Done."
  58.    end
  59.    return
  60.  
  61.  
  62. QueDelete: procedure expose MsgQ.
  63.    /**
  64.    ***  This will delete the message queues that were created for this
  65.    ***  session and restore the original queue back
  66.    **/
  67.  
  68.    code = RxQueue('Delete',MsgQ.Server)
  69.    code = RxQueue('Delete',MsgQ.Client)
  70.    MsgQ.Original  = RxQueue('Set'   ,MsgQ.Original)
  71.    return
  72.  
  73.  
  74. QueWaitForResponse: procedure expose MsgQ.
  75.    /**
  76.    ***  This will poll the REXX queue for any information coming in
  77.    **/
  78.  
  79.    parse arg Queue
  80.  
  81.    SaveQue  = RxQueue('Set',Queue)
  82.    do while queued() = 0
  83.       call SysSleep MsgQ.Sleep
  84.    end
  85.    return
  86.  
  87.  
  88. Post: procedure
  89.    /**
  90.    ***  This will send the message back to the client REXX queue
  91.    **/
  92.  
  93.    parse arg q msg params
  94.  
  95.    SaveQue  = RxQueue('Set',q)
  96.    queue msg params
  97.    code     = RxQueue('Set',SaveQue)
  98.    return
  99.