home *** CD-ROM | disk | FTP | other *** search
- /*-----------------------------Start Rexx Source------------------------------*/
-
-
- /* Magus!Cntl.rexx
-
- Magus! Print Spooler
- v1.00 Associated files: Magus!.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
-
- pm = false
- time2save = false
-
- top = " Top "
- bottom = "Bottom"
- left = " Left "
- center = "Center"
- right = "Right "
- page_on = "Page Numbering ON "
- page_off = "Page Numbering OFF"
- px0 = 120
- py0 = 71
- px1 = px0 + 18
- py1 = py0 + 14
- px2 = px1 + 58
- py2 = py1
-
- dx = 67
- dy = 48
- tx = dx + 75
- ty = dy
- fx = dx + 150
- fy = dy
- ds_on = "Date ON "
- ds_off = "Date OFF"
- ts_on = "Time ON "
- ts_off = "Time OFF"
- fs_on = "File Name ON "
- fs_off = "File Name OFF"
-
- config_file = Getenv('config_file')
- copy_dir = Getenv('copy_dir')
- file_separator = Getenv('file_separator')
- d_raw_options = Getenv('prt_options_raw')
- call GetOptions()
-
- sdhelp = "Enter Spooler Directory in gadget below\"
- sdhelp = sdhelp || "or leave null to print files ""In Place""."
-
- cphelp = "Enter number of copies to be\printed in gadget below."
-
- lphelp = "Enter number of lines/page to\be printed in gadget below."
-
- fshelp = "Enter file separator string\in gadget below.\\Backslash ""n"" = NEWLINE\Backslash ""f"" = FORMFEED"
-
- call MenuWindow2(MCNTLHOST,MCNTLPORT)
- call BuildControls()
- call SetAPen(MCNTLHOST,1)
- call SetOPen(MCNTLHOST,1)
-
- time2go = false
- time2exit = false
- all_ok = true
- do until(time2exit) /*5*/
- t = waitpkt(MCNTLPORT)
- do i = 1 /*6*/
- p = getpkt(MCNTLPORT)
- if c2d(p) = 0 then leave i
- command = getarg(p)
- select /*7*/
-
- when command = "COPIES" then call Copies()
-
- when command = "COPIES#" then call Copies_No()
-
- when command = "PAGE0" then call Page0()
-
- when command = "PAGE1" then call Page1()
-
- when command = "PAGE2" then call Page2()
-
- when command = "LINESPP" then
- do
- t = reply(p,0)
- call Request(100,100,lphelp,," OK ")
- end
-
- when command = "LPP#" then call LPP_No()
-
- when command = "DSTAMP" then call Dstamp()
-
- when command = "TSTAMP" then call Tstamp()
-
- when command = "FSTAMP" then call Fstamp()
-
- when command = "FILESEP" then
- do
- t = reply(p,0)
- call Request(100,100,fshelp,," OK ")
- end
-
- when command = "FILESS" then call Filess()
-
- when command = "USESETTINGS" then call Usesettings()
-
- when command = "SPOOLDIR" then
- do
- call Request(100,100,sdhelp,," OK ")
- end
-
- when command = "SPOOLNAM" then call Spoolnam()
-
- when command = "ABORT" then
- do
- t = reply(p,0)
- all_ok = false
- time2exit = true
- end
-
- when command = "LOADFILE" then call Loadfile()
-
- when command = "SAVEFILE" then call Savefile()
-
- otherwise
- t = reply(p,0)
- if time2go then time2exit = true
-
- end /*7*/
- end /*6*/
- end /*5*/
-
- if all_ok then call SetOptions()
- if pm then call PostMsg()
- call CloseWindow(MCNTLHOST)
-
- exit
-
- Copies:
- t = reply(p,0)
- call Request(100,100,cphelp,," OK ")
- return
-
- Copies_No:
- do i = 1 to 1
- text = getarg(p,1)
- t = reply(p,0)
- if verify(text,"0123456789") = 0 then
- if text > 0 then
- do
- copies = text
- leave i
- end
- call PostMsg(50,50,"WARNING!\\Number of Copies incorrect.")
- call Delay(150)
- call RemoveGadget(MCNTLHOST,"COPIES#")
- call AddGadget(MCNTLHOST, 7, 54,"COPIES#",copies,"%d%1%g",52)
- call PostMsg
- end
- return
-
- Page0:
- t = reply(p,0)
- if page_no then
- do
- page_no = false
- page0_stat = page_off
- lpp = "null"
- call RemoveGadget(MCNTLHOST,"LPP#")
- call AddGadget(MCNTLHOST, 7, 83,"LPP#",lpp,"%d%1%g",84)
- end
- else
- do
- page_no = true
- page0_stat = page_on
- if lpp = "null" then
- do
- lpp = 84
- call RemoveGadget(MCNTLHOST,"LPP#")
- call AddGadget(MCNTLHOST, 7, 83,"LPP#",lpp,"%d%1%g",84)
- end
- end
- call RemoveGadget(MCNTLHOST,"PAGE0")
- call RectFill(MCNTLHOST,px0,py0,px0+170,py1-2)
- call Addgadget(MCNTLHOST,px0,py0,"PAGE0",page0_stat,"%d")
- return
-
- Page1:
- t = reply(p,0)
- if page1_stat = top then
- do
- page1_stat = bottom
- torb = "b"
- end
- else
- do
- page1_stat = top
- torb = "t"
- end
- call RemoveGadget(MCNTLHOST,"PAGE1")
- call RectFill(MCNTLHOST,px1,py1,px1+55,py1+12)
- call AddGadget(MCNTLHOST,px1,py1,"PAGE1",page1_stat,"%d")
- return
-
- Page2:
- t = reply(p,0)
- if page2_stat = left then
- do
- page2_stat = center
- lrc = "c"
- end
- else if page2_stat = center then
- do
- page2_stat = right
- lrc = "r"
- end
- else
- do
- page2_stat = left
- lrc = "l"
- end
- call RemoveGadget(MCNTLHOST,"PAGE2")
- call RectFill(MCNTLHOST,px2,py2,px2+55,py2+12)
- call AddGadget(MCNTLHOST,px2,py2,"PAGE2",page2_stat,"%d")
- return
-
- LPP_No:
- do i = 1 to 1
- text = getarg(p,1)
- t = reply(p,0)
- if verify(text,"0123456789") = 0 then
- if text > 0 then
- do
- lpp = text
- leave i
- end
- else nop
- else if text = "null" then
- do
- lpp = text
- leave i
- end
- call PostMsg(50,50,"WARNING!\\Lines/page incorrect.")
- call Delay(150)
- call RemoveGadget(MCNTLHOST,"LPP#")
- call AddGadget(MCNTLHOST, 7, 83,"LPP#",lpp,"%d%1%g",84)
- call PostMsg()
- end
- return
-
- Dstamp:
- t = reply(p,0)
- if date_stat = ds_on then
- do
- date_stat = ds_off
- date = "off"
- end
- else
- do
- date_stat = ds_on
- date = "on"
- end
- call RemoveGadget(MCNTLHOST,"DSTAMP")
- call RectFill(MCNTLHOST,dx,dy,dx+71,dy+12)
- call AddGadget(MCNTLHOST, dx, dy,"DSTAMP",date_stat,"%d")
- return
-
- Tstamp:
- t = reply(p,0)
- if time_stat = ts_on then
- do
- time_stat = ts_off
- time = "off"
- end
- else
- do
- time_stat = ts_on
- time = "on"
- end
- call RemoveGadget(MCNTLHOST,"TSTAMP")
- call RectFill(MCNTLHOST,tx,ty,tx+71,ty+12)
- call AddGadget(MCNTLHOST, tx, ty,"TSTAMP",time_stat,"%d")
- return
-
- Fstamp:
- t = reply(p,0)
- if filename_stat = fs_on then
- do
- filename_stat = fs_off
- filename = "off"
- end
- else
- do
- filename_stat = fs_on
- filename = "on"
- end
- call RemoveGadget(MCNTLHOST,"FSTAMP")
- call RectFill(MCNTLHOST,fx,fy,fx+110,fy+12)
- call AddGadget(MCNTLHOST, fx, fy,"FSTAMP",filename_stat,"%d")
- return
-
- Filess:
- file_separator = getarg(p,1)
- t = reply(p,0)
- call RemoveGadget(MCNTLHOST,"FILESS")
- call AddGadget(MCNTLHOST,155, 26,"FILESS",file_separator,"%d%1%g",172)
- if time2go then time2exit = true
- if time2save then call ReadHost(MCNTLHOST,MCNTLPORT,"SAVEFILE")
- return
-
- Usesettings:
- t = reply(p,0)
- pm = true
- call PostMsg(50,50," OK! ")
- time2go = true
- call ReadGadget(MCNTLHOST,"SPOOLNAM")
- call ReadGadget(MCNTLHOST,"COPIES#")
- call ReadGadget(MCNTLHOST,"LPP#")
- call ReadGadget(MCNTLHOST,"FILESS")
- return
-
- Spoolnam:
- do i = 1 to 1
- text = getarg(p,1)
- t = reply(p,0)
- if text = copy_dir then leave i
- if (text = "" | text = "NULL" | text = "null") then copy_dir = "null"
- else if (~exists(text) | left(statef(text),1) ~= 'D') then
- do
- call PostMsg(50,50,"! WARNING \\"||text||" is not appropriate.\\Please reenter.")
- call delay(150)
- call RemoveGadget(MCNTLHOST,"SPOOLNAM")
- call AddGadget(MCNTLHOST, 7, 26,"SPOOLNAM",copy_dir,"%d%1%g",140)
- call PostMsg()
- end
- else
- do
- last_char = right(text,1)
- if last_char ~= ":" & last_char ~= "/" then text = text || "/"
- copy_dir = text || "$$M!Spool"
- if ~exists(copy_dir) then address command "makedir" copy_dir
- end
- end
- return
-
- Loadfile:
- t = reply(p,0)
- do until(exists(c_file) | c_file = "")
- c_file = GetFile(100,100,"S:*.config","MAGUS!.config","Select Config File")
- end
- if c_file ~= "" then
- do
- config_file_bak = config_file
- config_file = c_file
- call open('in',config_file,"Read")
- if readln('in') ~= "MAGUS! config file" then
- do
- call close('in')
- config_file = config_file_bak
- call PostMsg(50,50,"WARNING!\\Bad config file """||config_file||""".\\Skipping ""LOAD"".")
- call Delay(150)
- call PostMsg()
- end
- else
- do
- copy_dir = readln('in')
- file_separator = readln('in')
- d_raw_options = readln('in')
- call GetOptions()
- call close('in')
- call RemoveGs()
- call BackFill(MCNTLHOST)
- call BuildControls()
- end
- end
- return
-
- Savefile:
- t = reply(p,0)
- if ~time2save then
- do
- call PostMsg(50,50,"Saving Settings!")
- call ReadGadget(MCNTLHOST,"SPOOLNAM")
- call ReadGadget(MCNTLHOST,"COPIES#")
- call ReadGadget(MCNTLHOST,"LPP#")
- call ReadGadget(MCNTLHOST,"FILESS")
- time2save = true
- end
- else
- do
- do until(exists(c_file) | c_file = "")
- c_file = GetFile(100,100,"S:*.config","MAGUS!.config","Select Config File")
- end
- if c_file ~= "" then
- do
- config_file = c_file
- call open('out',config_file,"Write")
- call writeln('out',"MAGUS! config file")
- call writeln('out',copy_dir)
- call writeln('out',file_separator)
- if page_no then page = torb || lrc
- else page = "null"
- call writeln('out',copies||" "||lpp||" "||page||" "||date||" "||time||" "filename)
- call close('out')
- end
- time2save = false
- call PostMsg()
- end
- return
-
- /* Setup the host and open window for Magus! control display */
-
- MenuWindow2:
- arg hostcntl, hostport
-
- chfile = "T:$Magus2.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 = 'GADGETUP'
- flags = 'WINDOWDRAG+WINDOWDEPTH+BACKFILL'
-
- call PostMsg()
-
- call OpenWindow(hostcntl,0,23,335,136,idcmp,flags,"Magus! Controls")
-
- return 0
-
- /* Set print options environment variables */
-
- SetOptions:
- if page_no then page = torb || lrc
- else page = "null"
- d_raw_options = copies||" "||lpp||" "||page||" "||date||" "||time||" "filename
- rtn = Setenv('copy_dir',copy_dir)
- rtn = Setenv('file_separator',file_separator)
- rtn = Setenv('prt_options_raw',d_raw_options)
- rtn = Setenv('config_file',config_file)
-
- return
-
- /* Parse print options */
-
- GetOptions:
- parse VAR d_raw_options copies " " lpp " " page " " date " " time " " filename
- if page = "null" then
- do
- page_no = false
- page0_stat = page_off
- page1_stat = top
- torb = "t"
- page2_stat = right
- lrc = "r"
- end
- else
- do
- torb = left(page,1)
- lrc = right(page,1)
- page_no = true
- page0_stat = page_on
- if upper(torb) = "T" then page1_stat = top
- else page1_stat = bottom
- if upper(lrc) = "L" then page2_stat = left
- else if upper(lrc) = "C" then page2_stat = center
- else page2_stat = right
- end
- if date = "on" then date_stat = ds_on
- else date_stat = ds_off
- if time = "on" then time_stat = ts_on
- else time_stat = ts_off
- if filename = "on" then filename_stat = fs_on
- else filename_stat = fs_off
-
- return
-
- /* Build window control gadgets */
-
- BuildControls:
-
- call AddGadget(MCNTLHOST, 7, 14,"SPOOLDIR","Spooler Directory","%d")
- call AddGadget(MCNTLHOST, 7, 26,"SPOOLNAM",copy_dir,"%d%1%g",140)
- call AddGadget(MCNTLHOST,155, 14,"FILESEP","File Separator String","%d")
- call AddGadget(MCNTLHOST,155, 26,"FILESS",file_separator,"%d%1%g",172)
- call AddGadget(MCNTLHOST, 7, 42,"COPIES","Copies","%d")
- call AddGadget(MCNTLHOST, 7, 54,"COPIES#",copies,"%d%1%g",52)
- call AddGadget(MCNTLHOST, dx, dy,"DSTAMP",date_stat,"%d")
- call AddGadget(MCNTLHOST, tx, ty,"TSTAMP",time_stat,"%d")
- call AddGadget(MCNTLHOST, fx, fy,"FSTAMP",filename_stat,"%d")
- call AddGadget(MCNTLHOST, 7, 71,"LINESPP","Lines/Page","%d")
- call AddGadget(MCNTLHOST, 7, 83,"LPP#",lpp,"%d%1%g",84)
- call Addgadget(MCNTLHOST,px0,py0,"PAGE0",page0_stat,"%d")
- call AddGadget(MCNTLHOST,px1,py1,"PAGE1",page1_stat,"%d")
- call AddGadget(MCNTLHOST,px2,py2,"PAGE2",page2_stat,"%d")
-
- call AddGadget(MCNTLHOST, 10,120,"USESETTINGS"," USE ","%d")
- call AddGadget(MCNTLHOST, 89,120,"ABORT"," CANCEL ","%d")
- call AddGadget(MCNTLHOST,168,120,"LOADFILE"," LOAD ","%d")
- call AddGadget(MCNTLHOST,247,120,"SAVEFILE"," SAVE ","%d")
-
- return
-
- /* Remove all gadgets */
- RemoveGs:
-
- call RemoveGadget(MCNTLHOST,"SPOOLDIR")
- call RemoveGadget(MCNTLHOST,"SPOOLNAM")
- call RemoveGadget(MCNTLHOST,"FILESEP")
- call RemoveGadget(MCNTLHOST,"FILESS")
- call RemoveGadget(MCNTLHOST,"COPIES")
- call RemoveGadget(MCNTLHOST,"COPIES#")
- call RemoveGadget(MCNTLHOST,"DSTAMP")
- call RemoveGadget(MCNTLHOST,"TSTAMP")
- call RemoveGadget(MCNTLHOST,"FSTAMP")
- call RemoveGadget(MCNTLHOST,"LINESPP")
- call RemoveGadget(MCNTLHOST,"LPP#")
- call RemoveGadget(MCNTLHOST,"PAGE0")
- call RemoveGadget(MCNTLHOST,"PAGE1")
- call RemoveGadget(MCNTLHOST,"PAGE2")
-
- call RemoveGadget(MCNTLHOST,"USESETTINGS")
- call RemoveGadget(MCNTLHOST,"ABORT")
- call RemoveGadget(MCNTLHOST,"LOADFILE")
- call RemoveGadget(MCNTLHOST,"SAVEFILE")
-
- return
-
- /*-----------------------------End of Rexx Source-----------------------------*/
-