home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Otherware
/
Otherware_1_SB_Development.iso
/
amiga
/
misc
/
giuspool.lha
/
GUIprint.lzh
/
SpoolCtrl.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1992-05-19
|
8KB
|
246 lines
/************************************************************/
/* SpoolCtrl.rexx */
/* ARexx script for a GUI frontend to the spooler programs */
/* which are part of DanSpool 1.4, by Don Barrans. */
/* */
/* This script was written by Steven D. Kapplin */
/* CIS 70055,1021 5/16/92 */
/************************************************************/
/*****************************************************************/
/* Operation of this program should be self-evident. The window */
/* will contain various gadgets for controlling the spooler. */
/* Selecting Cancel will present a file requestor. You can */
/* select multiple files from the default SPOOL: directory to */
/* cancel the jobs. Spooled files are of the form prtnnnn where */
/* nnnn is a number from 0001 to however many jobs are in the */
/* queue. The Next and Last gadgets produce a file requestor */
/* from which you can select one file to move either to the top */
/* or the bottom of the queue. Suspend and Resume work as you */
/* would expect, they either suspend or resume spooling. The */
/* Print gadget will bring up a file requestor to select a file */
/* to print using the Print program. If you don't wish to use */
/* Print to print a file, then just ignore it. Query will open */
/* a shell window and display current information on the content */
/* of the queue. The two top gadgets, Enable and Disable spool */
/* directory either assign SPOOL: to a default directory which */
/* contained in this script in the variable, spoooldir. You can */
/* change this to the one you use. Disable simple does an */
/* Assign SPOOL: to de-assign the directory. Spooling is dis- */
/* abled when you do this. The bottom left gadget, Create is */
/* used to create a SPOOL: directory of your choice if you don't */
/* create the assignment during boot-up. The Quit gadget should */
/* be obvious. You can pass a default directory for SPOOL: when */
/* you run this script -- Spooler dir -- is the syntax. You */
/* will need ARexx, RexxArpLib.library, and Arp.library to use */
/* this macro. Since I use RexxArpLib 3.0, everything is set up */
/* to expect AmigaDos 2.04. You may need to alter things if you */
/* don't yet have 2.04. You will also need Dan Barrans' spool */
/* programs. The archive is DanSpl14.lzh and can be found in */
/* various places such as Compuserve. If you recently down- */
/* loaded this archive, you may find this script in it. */
/*****************************************************************/
trace OFF
parse arg spooldir
if ~show('L','rexxsupport.library') then
call addlib('rexxsupport.library',0,-30,0)
if ~show('L','rexxarplib.library') then
call addlib('rexxarplib.library',0,-30,0)
host = 'SPOOLHOST'
port = 'SPOOLPORT'
do i = 1 while show('p',host||i)
end
host = host||i
port = port||i
/* PrintC options */
QUERY = 'Q'
CANCEL = 'C'
NEXT = 'N'
LAST = 'L'
SUSPEND = 'S'
RESUME = 'R'
if spooldir = '' then spooldir = 'DH8:Spool'
cdir = pragma('D')
/* shell */
newshell = 'NewWsh con:75/135/540/200/Spooler/c CMD '
/* setup some variables for program */
win_title = 'Spool Control'
scrwid = ScreenCols('Workbench')
scrht = ScreenRows('Workbench')
width = 298
height = 140
idcmp = 'CLOSEWINDOW+GADGETUP'
flags = 'WINDOWCLOSE+WINDOWDEPTH+WINDOWDRAG'
/* open main program window */
xpos = (scrwid-width)%2
ypos = (scrht-height)%2
reqwid = 298
reqht = 175
err = MenuWindow(host,port,win_title,xpos,ypos,width,height,idcmp,flags)
IF err ~= 0 THEN DO
SAY 'Could not open host ... Aborting'
SAY
exit
END
/* set up window gadgets */
call AddGadget(host,77,15,1,center('Enable Spool Dir',18),'ENABLE')
call AddGadget(host,77,30,2,center('Disable Spool Dir',18),'DISABLE')
call Move(host,17,53)
call SetAPen(host,2)
call Text(host,'---------------------------------')
call AddGadget(host,252,124,3,'Quit','QUIT')
call AddGadget(host,15,60,4,'Query ','QUERY')
call AddGadget(host,223,60,5,'Suspend','SUSPEND')
call AddGadget(host,15,75,6,'Cancel','CANCEL')
call AddGadget(host,223,75,7,'Resume ','RESUME')
call AddGadget(host,15,90,8,' Next ','NEXT')
call AddGadget(host,15,105,9,' Last ','LAST')
call AddGadget(host,223,90,10,' Print ','PRINT')
call AddGadget(host,15,124,11,'Create Spool Dir','CREATE')
call box(host,1,2,110,68,80,23)
call SetDrMd(host,'JAM2')
if statef('SPOOL:') ~= '' then call activemsg()
else call inactivemsg()
/* main program loop */
DO forever
if quitflag = 1 then leave
t = waitpkt(port)
do ff = 1
p = getpkt(port)
if c2d(p) = 0 then leave ff
gadid = getarg(p)
t = reply(p,0)
if gadid = 'CLOSEWINDOW' | gadid = 'QUIT' then do
call closewindow(host)
quitflag = 1
leave ff
end
SELECT
WHEN gadid = 'ENABLE' then do
address COMMAND 'assign SPOOL: ' spooldir
call activemsg()
END
WHEN gadid = 'DISABLE' then do
if exists('SPOOL:') then address COMMAND 'assign SPOOL:'
call inactivemsg()
END
WHEN gadid = 'QUERY' then do
cmd = 'PrintC ' QUERY
address COMMAND newshell cmd
END
WHEN gadid = 'SUSPEND' then address COMMAND 'PrintC ' SUSPEND
WHEN gadid = 'RESUME' then address COMMAND 'PrintC ' RESUME
WHEN gadid = 'CANCEL' then do
files.0 = ''
jobnums = ''
result = GetFile(xpos,ypos,'SPOOL:',,'Select Job File to Cancel','Workbench','MULTISELECT+PATGAD+MATCHDIRS',files,reqwid,reqht,'prt????')
do i = 1 to files.0
jobnums = jobnums right(files.i,4)
end
if files.0 > 0 then address COMMAND 'PrintC ' CANCEL ' ' jobnums
END
WHEN gadid = 'NEXT' then do
fname = GetFile(xpos,ypos,'SPOOL:',,'Select Job File to Move','Workbench','PATGAD+MATCHDIRS',,reqwid,reqht,'prt????')
if exists(fname) & fname ~= '' then do
jobnum = right(fname,4)
address COMMAND 'PrintC ' NEXT ' ' jobnum
end
END
WHEN gadid = 'LAST' then do
fname = GetFile(xpos,ypos,'SPOOL:',,'Select Job File to Move','Workbench','PATGAD+MATCHDIRS',,reqwid,reqht,'prt????')
if exists(fname) & fname ~= '' then do
jobnum = right(fname,4)
address COMMAND 'PrintC ' LAST ' ' jobnum
end
END
WHEN gadid = 'PRINT' then do
fname = GetFile(xpos,ypos,cdir,,'Select File to Print','Workbench',,,reqwid,reqht)
if exists(fname) & fname ~= '' then do
address COMMAND 'Print ' fname ' NONUM'
end
END
WHEN gadid = 'CREATE' then do
dirname = GetFile(xpos,ypos,,,'Select or Enter Directory','Workbench','NOFILES',,reqwid,reqht)
if dirname ~= '' then do
spooldir = dirname
address COMMAND 'makedir ' spooldir
end
END
OTHERWISE NOP
END
END
END
EXIT
activemsg:
call SetAPen(host,3)
call Move(host,114,77)
call Text(host,'Spool Dir')
call Move(host,118,87)
call Text(host,' Active ')
return
inactivemsg:
call SetAPen(host,1)
call Move(host,114,77)
call Text(host,'Spool Dir')
call Move(host,118,87)
call Text(host,'InActive')
return
box: procedure
ARG boxhost,pen1,pen2,upleft,uptop,width,height
CALL SetAPen(boxhost,pen2)
CALL Move(boxhost,upleft+width+1,uptop)
CALL Draw(boxhost,upleft+width+1,uptop+height)
CALL Draw(boxhost,upleft-1,uptop+height)
CALL Move(boxhost,upleft+width,uptop+1)
CALL Draw(boxhost,upleft+width,uptop+height)
CALL SetAPen(boxhost,pen1)
CALL Move(boxhost,upleft,uptop)
CALL Draw(boxhost,upleft+width,uptop)
CALL Move(boxhost,upleft,uptop+height-1)
CALL Draw(boxhost,upleft,uptop)
CALL Move(boxhost,upleft-1,uptop)
CALL Draw(boxhost,upleft-1,uptop+height)
RETURN
MenuWindow: procedure
parse arg menuhost, menuport, win_title, xpos, ypos, width, height, idcmp, flags
address AREXX "'call createhost(" menuhost "," menuport ")'"
mp = openport(menuport)
'waitforport' menuport
if ~(mp & showlist('p',menuport)) then return 5
/* Open the menu window in the upper left-hand corner */
call OpenWindow(menuhost,xpos,ypos,width,height,idcmp, flags,win_title)
return 0