home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / skeleton.zip / QueCmd.cmd < prev    next >
OS/2 REXX Batch file  |  1995-08-03  |  3KB  |  74 lines

  1. /*****************************************************************************\
  2. | Places the result of an OS/2 command in the program stack.                  |
  3. |                                                                             |
  4. | $Revision:   1.0  $
  5. |     $Date:   03 Aug 1995 20:10:22  $                                        |
  6. | Libraries:   REXXSAA, REXXUTIL                                              |
  7. |  Category:   Utility                                                        |
  8. |     Class:   Program                                                        |
  9. |      Type:   Queue                                                          |
  10. |    Author:   Bob Rice - CompuServe: 72421,3016                              |
  11. |                                                                             |
  12. | Copyright (c) 1995 Empirical Heuristics                                     |
  13. \**************************************************************************r4*/
  14. /*  !tr! = value('TRACE',,'OS2ENVIRONMENT'); parse source . . !who!          */
  15. /*  if !tr! \= '' then say '--> Entering' !who!; trace value !tr!; nop       */
  16.   if arg(1) = '' | left(arg(1),1) = '?' then do
  17.     parse source . . !pgm!; call TellHelp arg(1), !pgm!; exit 2; end
  18.  
  19.   parse arg cmd, opts
  20.   if wordpos('/LIFO', translate(opts)) > 0 then lifo = 1
  21.                                            else lifo = 0
  22.   onque = queued()                              /* Lines already on queue    */
  23.   if lifo then do                               /* Just add command results  */
  24.     '@'cmd '| RxQueue /LIFO'
  25.     queued = queued() - onque
  26.   end
  27.   else do
  28.     do i = 1 to onque                           /* Save queue contents       */
  29.       parse pull oldline.i
  30.     end
  31.     '@'cmd '| RxQueue /FIFO'                    /* Put cmd results on queue  */
  32.     queued = queued()
  33.     do i = 1 to onque                           /* Restore saved contents    */
  34.       queue oldline.i
  35.     end
  36.   end
  37.   exit queued                                   /* Number of lines in result */
  38. /*--Begin Help-----------------------------------------------------------------
  39. This routine executes the specified OS/2 command and places the output, which
  40. is normally written to the console, into the program stack.  It returns the
  41. number of lines it has placed in the stack.  If /LIFO is specified, the lines
  42. are queued in the stack in reverse order.  If there already are lines on the
  43. stack before this program is called, then using /LIFO is faster than not using
  44. it, since no special handling of the existing lines is required.
  45.  
  46. Params: command [, /LIFO ]
  47.  
  48. ________________
  49. Alternate Params: [ ? | ?? | ??? | ???? ]
  50.  
  51. where:
  52.  
  53.   ?     Displays up to the "Syntax:" or "Params:" portion of this help text.
  54.  
  55.   ??    Displays this entire help text except for the technical information.
  56.  
  57.   ???   Displays this entire help text.
  58.  
  59.   ????  Puts this help text into a file whose name is the same as the name of
  60.         this program and whose extent is .ABS.  The file is written to the same
  61.         directory as that in which this program resides.
  62.  
  63. _______________
  64. Technical Notes
  65.  
  66. ___________________
  67. Development History
  68.  
  69. $Log:   Q:/rxdv/skeleton/vcs/quecmd.cm!  $
  70.   
  71.      Rev 1.0   03 Aug 1995 20:10:22
  72.   Initial revision.
  73. --End Help-------------------------------------------------------------------*/
  74.