home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
216.lha
/
Magus!
/
Magus!.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-02-15
|
9KB
|
270 lines
/*-----------------------------Start Rexx Source------------------------------*/
/* Magus!.rexx
Magus! Print Spooler
v1.00 Associated files: Magus!Cntl.rexx
Magus!Util.rexx
by MPrint.rexx
Dan Schenck MPrintIt.rexx
Tulsa, OK
GEnie: D.SCHENCK
(918) 492-0523
*/
/* Requires rexxarplib.library v2.1 */
true = 1
false = 0
sufile = "T:$$M!Util"
title = " Magus! "
sysinfo = "Magus! Print Spooler v1.00\"
sysinfo = sysinfo || " Written by:\ Dan Schenck\\"
sysinfo = sysinfo || " Tulsa, Oklahoma"
syshelp = "To activate print file selector\"
syshelp = syshelp || "use pull down menu ""Print File"".\\"
syshelp = syshelp || "To change printer control settings\"
syshelp = syshelp || "select ""Active/Inactive"" gadget\"
syshelp = syshelp || "on Magus! window."
active = " Active "
inactive = " Inactive "
status = inactive
config_file = "S:MAGUS!.config"
rtn = Setenv('prnt_spooler',"NA")
rtn = Setenv('spool_tail','null')
prnt_done = true
time2exit = false
count = 0
/* Open primary Magus! window */
call MenuWindow1(MAGUSHOST,MAGUSPORT)
call AddMenu(MAGUSHOST,"System ")
call AddItem(MAGUSHOST," About Magus! ","SYSINFO")
call AddItem(MAGUSHOST," Spooler Help ","SYSHELP")
call AddMenu(MAGUSHOST,"Options")
call AddItem(MAGUSHOST," Print File ","PRINTSEL","P")
call AddItem(MAGUSHOST," List Print Queue ","LISTQ","Q")
call AddItem(MAGUSHOST," Abort Print Job ","ABORTJOB","A")
call AddGadget(MAGUSHOST,7,23,"CONTROL",status,"%d")
call AddGadget(MAGUSHOST,7,11,"SYSINFO",title,"%d")
time2quit = false
time2end = false
call ReadHost(MAGUSHOST,MAGUSPORT,"SETUP")
do until(time2quit) /*1*/
t = waitpkt(MAGUSPORT)
i = false
do until(i) /*2*/
p = getpkt(MAGUSPORT)
if c2d(p) = 0 then break
command = getarg(p)
t = reply(p,0)
i = true
select /*3*/
when command = "PRINT" then
do
do while(Getenv('prnt_spooler') = 'GETTINGCLIP')
call delay(25)
end
rtn = Setenv('prnt_spooler','GETTINGCLIP')
instring = Getenv('next_file2print')
rtn = Setenv('next_file2print','[READY]')
rtn = Setenv('prnt_spooler','NA')
parse VAR instring file2print '^' options
if left(statef(file2print),4) ~= "FILE" then break
orig_file = file2print
copy_dir = Getenv('copy_dir')
if copy_dir ~= "null" then
do
count = count + 1
copy_file = copy_dir || "/$$" || count
address command 'copy' file2print " TO " copy_file
file2print = copy_file
end
do while(Getenv('prnt_spooler') = 'GETTINGCLIP')
call delay(25)
end
rtn = Setenv('prnt_spooler','GETTINGCLIP')
spool_tail = Getenv('spool_tail')
if spool_tail = "null" then
do
fwrd_pointer = 'spool_1'
spool_tail = 1
end
else
do
back_pointer = 'spool_' || spool_tail
spool_tail = spool_tail + 1
fwrd_pointer = 'spool_' || spool_tail
file_info = Getenv(back_pointer)
file_info = fwrd_pointer subword(file_info,2)
rtn = Setenv(back_pointer,file_info)
end
file_info = 'null' file2print orig_file options
rtn = Setenv(fwrd_pointer,file_info)
rtn = Setenv('spool_tail',spool_tail)
rtn = Setenv('prnt_spooler','NA')
if prnt_done then
do
address command arun "rx rexx:mprintit" fwrd_pointer Getenv('file_separator')
prnt_done = false
call RemoveGadget(MAGUSHOST,"CONTROL")
status = active
call BackFill(MAGUSHOST)
call RefreshGadgets(MAGUSHOST)
call AddGadget(MAGUSHOST,7,23,"CONTROL",status,"%d")
end
end
when command = "DONE" then
do
if time2exit then call EndAll
prnt_done = true
count = 0
call RemoveGadget(MAGUSHOST,"CONTROL")
status = inactive
call BackFill(MAGUSHOST)
call RefreshGadgets(MAGUSHOST)
call AddGadget(MAGUSHOST,7,23,"CONTROL",status,"%d")
end
when command = "SETUP" then
do
if ~exists(config_file) then
do
call PostMsg(50,50,"Creating MAGUS! config file.\\To alter attributes\select ""Active/Inactive"" gadget.")
copy_dir = "null"
file_separator = "\n"
d_raw_options = "1 null null on on on"
done = false
call SetOptions()
call open('out',config_file,"Write")
call writeln('out',"MAGUS! config file")
call writeln('out',copy_dir)
call writeln('out',file_separator)
call writeln('out',d_raw_options)
call close('out')
call Delay(100)
call PostMsg()
end
else
do
call open('in',config_file,"Read")
if readln('in') ~= "MAGUS! config file" then
do
call close('in')
call PostMsg(50,50,"WARNING!\\Bad config file """||config_file||""".\\Will replace with Default File.")
address command delete config_file
address command arun "rx" "rexx:Magus!Setup"
call Delay(100)
call PostMsg()
end
else
do
copy_dir = readln('in')
file_separator = readln('in')
d_raw_options = readln('in')
call close('in')
call SetOptions()
if copy_dir ~= "null" & ~exists(copy_dir) then address command "makedir" copy_dir
end
end
end
when command = "PRINTSEL" then address command arun "rx" "rexx:Mprint"
when command = "LISTQ" | command = "ABORTJOB" then
do
if prnt_done then
do
call PostMsg(50,50,"WARNING!\Print program not active.")
call Delay(150)
call PostMsg()
end
else
do
call open('out',sufile,"Write")
call writeln('out',"rx rexx:Magus!Util "||command)
call writeln('out',"endcli")
call close('out')
ys = ScreenRows()/2
address command "NewShell" ">NIL: NEWCON:0/"||ys||"/"||Screencols()||"/"||ys||"/Magus!Queue from" sufile
end
end
when command = "CLOSEWINDOW" then
do
if prnt_done then call EndAll
call PostMsg(50,50,"Waiting on print to\complete before exiting.")
call delay(150)
call PostMsg()
time2exit = true
end
when command = "SYSINFO" then call Request(100,100,sysinfo,," OK ")
when command = "SYSHELP" then call Request( 50, 50,syshelp,," OK ")
when command = "CONTROL" then
do /*4*/
call PostMsg(50,50,"Building Control Panel")
address REXX "rexx:Magus!Cntl"
end /*4*/
otherwise say command
end /*3*/
end /*2*/
end /*1*/
exit
EndAll:
call CloseWindow(MAGUSHOST)
exit
/* Setup the host and open window for primary Magus! display */
MenuWindow1:
arg hostcntl, hostport
chfile = "T:$Magus1.rexx"
if ~exists(chfile) then
do
call open('out',chfile,"Write")
call writeln('out',"/* Start Rexx Source */")
call writeln('out',"x = createhost(" || hostcntl || "," || hostport || ")")
call close('out')
end
address command arun "rx" chfile
mp = openport(hostport)
address command "c:WaitForPort" hostcntl
address command "c:WaitForPort" hostport
do until(showlist("P",hostcntl) & showlist("P",hostport))
call delay(10)
end
idcmp = 'CLOSEWINDOW+GADGETUP+MENUPICK'
flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+BACKFILL'
call OpenWindow(hostcntl,0,0,98,37,idcmp,flags,"M")
return 0
/* Set print options environment variables */
SetOptions:
rtn = Setenv('copy_dir',copy_dir)
rtn = Setenv('file_separator',file_separator)
rtn = Setenv('prt_options_raw',d_raw_options)
rtn = Setenv('next_file2print',"[READY]")
rtn = Setenv('config_file',config_file)
return
/*-----------------------------End of Rexx Source-----------------------------*/