home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / misc / giuspool.lha / GUIprint.lzh / SpoolCtrl.rexx < prev   
OS/2 REXX Batch file  |  1992-05-19  |  8KB  |  246 lines

  1. /************************************************************/
  2. /* SpoolCtrl.rexx                                    */
  3. /* ARexx script for a GUI frontend to the spooler programs    */
  4. /* which are part of DanSpool 1.4, by Don Barrans.        */
  5. /*                                                */
  6. /* This script was written by Steven D. Kapplin            */
  7. /* CIS 70055,1021    5/16/92                            */
  8. /************************************************************/
  9.  
  10. /*****************************************************************/
  11. /* Operation of this program should be self-evident.  The window    */
  12. /* will contain various gadgets for controlling the spooler.    */
  13. /* Selecting Cancel will present a file requestor.  You can     */
  14. /* select multiple files from the default SPOOL: directory to    */
  15. /* cancel the jobs.  Spooled files are of the form prtnnnn where    */
  16. /* nnnn is a number from 0001 to however many jobs are in the     */
  17. /* queue.  The Next and Last gadgets produce a file requestor    */
  18. /* from which you can select one file to move either to the top    */
  19. /* or the bottom of the queue.  Suspend and Resume work as you     */
  20. /* would expect, they either suspend or resume spooling.  The    */
  21. /* Print gadget will bring up a file requestor to select a file    */
  22. /* to print using the Print program.  If you don't wish to use    */
  23. /* Print to print a file, then just ignore it.  Query will open    */
  24. /* a shell window and display current information on the content    */
  25. /* of the queue.  The two top gadgets, Enable and Disable spool    */
  26. /* directory either assign SPOOL: to a default directory which     */
  27. /* contained in this script in the variable, spoooldir.  You can    */
  28. /* change this to the one you use.  Disable simple does an        */
  29. /* Assign SPOOL: to de-assign the directory.  Spooling is dis-    */
  30. /* abled when you do this.  The bottom left gadget, Create is    */
  31. /* used to create a SPOOL: directory of your choice if you don't    */
  32. /* create the assignment during boot-up.  The Quit gadget should    */
  33. /* be obvious.  You can pass a default directory for SPOOL: when    */
  34. /* you run this script -- Spooler dir -- is the syntax.  You     */
  35. /* will need ARexx, RexxArpLib.library, and Arp.library to use    */
  36. /* this macro.  Since I use RexxArpLib 3.0, everything is set up    */
  37. /* to expect AmigaDos 2.04.  You may need to alter things if you    */
  38. /* don't yet have 2.04.    You will also need Dan Barrans' spool    */
  39. /* programs.  The archive is DanSpl14.lzh and can be found in    */
  40. /* various places such as Compuserve.  If you recently down-    */
  41. /* loaded this archive, you may find this script in it.        */
  42. /*****************************************************************/
  43.  
  44. trace OFF
  45. parse arg spooldir
  46.  
  47. if ~show('L','rexxsupport.library') then
  48.    call addlib('rexxsupport.library',0,-30,0)
  49. if ~show('L','rexxarplib.library') then
  50.    call addlib('rexxarplib.library',0,-30,0)
  51.  
  52. host = 'SPOOLHOST'
  53. port = 'SPOOLPORT'
  54.  
  55. do i = 1 while show('p',host||i)
  56. end
  57. host = host||i
  58. port = port||i
  59.  
  60. /* PrintC options */
  61.  
  62. QUERY    = 'Q'
  63. CANCEL    = 'C'
  64. NEXT        = 'N'
  65. LAST        = 'L'
  66. SUSPEND    = 'S'
  67. RESUME    = 'R'
  68. if spooldir = '' then spooldir = 'DH8:Spool'
  69. cdir = pragma('D')
  70. /* shell    */
  71.  
  72. newshell = 'NewWsh con:75/135/540/200/Spooler/c CMD '
  73.  
  74. /* setup some variables for program */
  75.  
  76. win_title = 'Spool Control'
  77. scrwid = ScreenCols('Workbench')
  78. scrht = ScreenRows('Workbench')
  79. width = 298
  80. height = 140
  81. idcmp = 'CLOSEWINDOW+GADGETUP'
  82. flags = 'WINDOWCLOSE+WINDOWDEPTH+WINDOWDRAG'
  83.  
  84. /* open main program window    */
  85.  
  86. xpos = (scrwid-width)%2
  87. ypos = (scrht-height)%2
  88. reqwid = 298
  89. reqht = 175
  90.  
  91. err = MenuWindow(host,port,win_title,xpos,ypos,width,height,idcmp,flags)
  92.  
  93. IF err ~= 0 THEN DO
  94.     SAY 'Could not open host ... Aborting'
  95.     SAY
  96.     exit
  97. END
  98.  
  99. /* set up window gadgets */
  100.  
  101. call AddGadget(host,77,15,1,center('Enable Spool Dir',18),'ENABLE')
  102. call AddGadget(host,77,30,2,center('Disable Spool Dir',18),'DISABLE')
  103. call Move(host,17,53)
  104.  
  105. call SetAPen(host,2)
  106. call Text(host,'---------------------------------')
  107.  
  108. call AddGadget(host,252,124,3,'Quit','QUIT')
  109. call AddGadget(host,15,60,4,'Query ','QUERY')
  110. call AddGadget(host,223,60,5,'Suspend','SUSPEND')
  111. call AddGadget(host,15,75,6,'Cancel','CANCEL')
  112. call AddGadget(host,223,75,7,'Resume ','RESUME')
  113. call AddGadget(host,15,90,8,' Next ','NEXT')
  114. call AddGadget(host,15,105,9,' Last ','LAST')
  115. call AddGadget(host,223,90,10,' Print ','PRINT')
  116. call AddGadget(host,15,124,11,'Create Spool Dir','CREATE')
  117.  
  118. call box(host,1,2,110,68,80,23)
  119.  
  120. call SetDrMd(host,'JAM2')
  121.  
  122. if statef('SPOOL:') ~= '' then call activemsg()
  123.    else call inactivemsg()
  124.  
  125. /* main program loop */
  126.  
  127. DO forever
  128.     if quitflag = 1 then leave
  129.     t = waitpkt(port)
  130.     do ff = 1
  131.         p = getpkt(port)
  132.         if c2d(p) = 0 then leave ff
  133.         gadid = getarg(p)
  134.         t = reply(p,0)
  135.         if gadid = 'CLOSEWINDOW' | gadid = 'QUIT' then do
  136.             call closewindow(host)
  137.             quitflag = 1
  138.             leave ff
  139.         end
  140.  
  141.         SELECT
  142.             WHEN gadid = 'ENABLE' then do
  143.                 address COMMAND 'assign SPOOL: ' spooldir
  144.                 call activemsg()
  145.             END
  146.             WHEN gadid = 'DISABLE' then do
  147.                 if exists('SPOOL:') then    address COMMAND 'assign SPOOL:'
  148.                 call inactivemsg()
  149.             END
  150.             WHEN gadid = 'QUERY' then do
  151.                 cmd = 'PrintC ' QUERY
  152.                 address COMMAND newshell cmd
  153.             END
  154.             WHEN gadid = 'SUSPEND' then address COMMAND 'PrintC ' SUSPEND
  155.             WHEN gadid = 'RESUME' then address COMMAND 'PrintC ' RESUME
  156.             WHEN gadid = 'CANCEL' then do
  157.                 files.0 = ''
  158.                 jobnums = ''
  159.                 result = GetFile(xpos,ypos,'SPOOL:',,'Select Job File to Cancel','Workbench','MULTISELECT+PATGAD+MATCHDIRS',files,reqwid,reqht,'prt????')
  160.                 do i = 1 to files.0
  161.                     jobnums = jobnums right(files.i,4)
  162.                 end
  163.                 if files.0 > 0 then address COMMAND 'PrintC ' CANCEL ' ' jobnums
  164.             END
  165.             WHEN gadid = 'NEXT' then do
  166.                 fname = GetFile(xpos,ypos,'SPOOL:',,'Select Job File to Move','Workbench','PATGAD+MATCHDIRS',,reqwid,reqht,'prt????')
  167.                 if exists(fname) & fname ~= '' then do
  168.                     jobnum = right(fname,4)
  169.                     address COMMAND 'PrintC ' NEXT ' ' jobnum
  170.                 end
  171.             END
  172.             WHEN gadid = 'LAST' then do
  173.                 fname = GetFile(xpos,ypos,'SPOOL:',,'Select Job File to Move','Workbench','PATGAD+MATCHDIRS',,reqwid,reqht,'prt????')
  174.                 if exists(fname) & fname ~= '' then do
  175.                     jobnum = right(fname,4)
  176.                     address COMMAND 'PrintC ' LAST ' ' jobnum
  177.                 end
  178.             END
  179.             WHEN gadid = 'PRINT' then do
  180.                 fname = GetFile(xpos,ypos,cdir,,'Select File to Print','Workbench',,,reqwid,reqht)
  181.                 if exists(fname) & fname ~= '' then do
  182.                     address COMMAND 'Print ' fname ' NONUM'
  183.                 end
  184.             END
  185.             WHEN gadid = 'CREATE' then do
  186.                 dirname = GetFile(xpos,ypos,,,'Select or Enter Directory','Workbench','NOFILES',,reqwid,reqht)
  187.                 if dirname ~= '' then do
  188.                     spooldir = dirname
  189.                     address COMMAND 'makedir ' spooldir
  190.                 end
  191.             END
  192.             OTHERWISE NOP
  193.         END
  194.     END
  195. END
  196.  
  197. EXIT
  198.  
  199. activemsg:
  200.     call SetAPen(host,3)
  201.     call Move(host,114,77)
  202.     call Text(host,'Spool Dir')
  203.     call Move(host,118,87)
  204.     call Text(host,' Active ')
  205. return
  206.  
  207. inactivemsg:
  208.     call SetAPen(host,1)
  209.     call Move(host,114,77)
  210.     call Text(host,'Spool Dir')
  211.     call Move(host,118,87)
  212.     call Text(host,'InActive')
  213. return
  214.  
  215. box: procedure
  216.   ARG boxhost,pen1,pen2,upleft,uptop,width,height
  217.   CALL SetAPen(boxhost,pen2)
  218.   CALL Move(boxhost,upleft+width+1,uptop)
  219.   CALL Draw(boxhost,upleft+width+1,uptop+height)
  220.   CALL Draw(boxhost,upleft-1,uptop+height)
  221.   CALL Move(boxhost,upleft+width,uptop+1)
  222.   CALL Draw(boxhost,upleft+width,uptop+height)
  223.   CALL SetAPen(boxhost,pen1)
  224.   CALL Move(boxhost,upleft,uptop)
  225.   CALL Draw(boxhost,upleft+width,uptop)
  226.   CALL Move(boxhost,upleft,uptop+height-1)
  227.   CALL Draw(boxhost,upleft,uptop)
  228.   CALL Move(boxhost,upleft-1,uptop)
  229.   CALL Draw(boxhost,upleft-1,uptop+height)
  230. RETURN
  231.  
  232. MenuWindow: procedure
  233.     parse arg menuhost, menuport, win_title, xpos, ypos, width, height, idcmp, flags
  234.     address AREXX  "'call createhost(" menuhost "," menuport ")'"
  235.  
  236.     mp = openport(menuport)
  237.     'waitforport' menuport
  238.  
  239.     if ~(mp & showlist('p',menuport)) then return 5
  240.  
  241.  
  242. /* Open the menu window in the upper left-hand corner */
  243.     call OpenWindow(menuhost,xpos,ypos,width,height,idcmp, flags,win_title)
  244.  
  245. return 0
  246.