home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
216.lha
/
Magus!
/
MPrintIt.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-02-15
|
7KB
|
239 lines
/*---------------------------- Start REXX Source ----------------------------*/
/* MPrintIt.rexx Revised 27-FEB-89
Magus! Print Spooler
v1.00 Associated files: Magus!.rexx
Magus!Cntl.rexx
by Magus!Util.rexx
Dan Schenck MPrint.rexx
Tulsa, OK
GEnie: D.SCHENCK
(918) 492-0523
*/
/* Requires rexxarplib.library v2.1 */
parse arg head_pointer cc
schar = '\f'
rchar = '0C'X
call look4spec_char
schar = '\n'
rchar = '0A'X
call look4spec_char
rtn = Setenv('printit_pgm','ACTIVE')
do forever
rtn = Setenv('current_print',head_pointer)
rtn = Setenv('%_read',0)
do while(Getenv('prnt_spooler') = 'GETTINGCLIP')
call delay(25)
end
rtn = Setenv('prnt_spooler','GETTINGCLIP')
instring = Getenv(head_pointer)
rtn = Setenv('prnt_spooler','NA')
parse VAR instring fwrd_pointer ' ' file2print ' ' orig_file ' ' copies ' ' lpp ' ' p_no ' ' date ' ' time ' ' file
call printit
do while(Getenv('prnt_spooler') = 'GETTINGCLIP')
call delay(25)
end
rtn = Setenv('prnt_spooler','GETTINGCLIP')
instring = Getenv(head_pointer)
parse VAR instring fwrd_pointer ' ' rest
rtn = Setenv(head_pointer,'null')
if fwrd_pointer = 'null' then
do
rtn = Setenv('printit_pgm','NA')
rtn = Setenv('current_print','null')
rtn = Setenv('spool_tail','null')
rtn = Setenv('prnt_spooler','NA')
address "MAGUSPORT" "DONE"
exit
end
rtn = Setenv('prnt_spooler','NA')
head_pointer = fwrd_pointer
end
printit: procedure expose file2print orig_file cc copies lpp p_no date time file
address command
interrupt = 'NOTE---> PRINT PROCESS INTERRUPTED'
if ~exists(file2print) then
do
say '"' || file2print || '" Does Not Exist"'
return
end
total_bytes = copies * word(statef(file2print),2)
bytes_read = 0
if lpp ~= 'null' then
do
count_lines = 1
if (p_no ~= 'null') & (substr(p_no,1,1) = 'b') then lpp = lpp - 2
else nop
end
else count_lines = 0
dt_string = ""
file_string = ""
if upper(date) = 'ON' then dt_string = 'Date: ' || date() || ' '
if upper(time) = 'ON' then dt_string = dt_string || 'Time: ' || time()
if upper(file) = 'ON' then file_string = 'File: ' || orig_file
do i = 1 to copies
call time('Reset')
total_lines = 0
count = 0
page = -1
do while(~open('out','PRT:','Write'))
call delay(300)
end
if count_lines then
do
call new_page
call page_minder(cc)
if dt_string ~= "" then call page_minder(dt_string)
else nop
if file_string ~= "" then call page_minder(file_string)
else nop
call page_minder(' ')
end
else
do
call writeln('out',cc)
if dt_string ~= "" then call writeln('out',dt_string)
if file_string ~= "" then call writeln('out',file_string)
call writeln('out',' ')
end
prntfile = 'pfile'
call open(prntfile,file2print,'Read')
total_rcds = 0
rec_chk = 10
do while(~eof(prntfile))
if Getenv('printit_pgm') = 'ABORT' then
do
call close(prntfile)
if count_lines then call page_minder(interrupt)
else call writeln('out',interrupt)
call close('out')
if (index(upper(file2print),"$$M!SPOOL/$$") > 0) then
'delete' file2print || " Quiet"
rtn = Setenv('printit_pgm','ACTIVE')
return
end
instring = readln(prntfile)
bytes_read = bytes_read + length(instring)
total_rcds = total_rcds + 1
if total_rcds = rec_chk then
do
rec_chk = rec_chk + 10
rtn = Setenv('%_read',(bytes_read/total_bytes*100))
end
if count_lines then
do
if right(instring,1) = '0C'X then
do
if count >= lpp then call new_page
else nop
call writeln('out',left(instring,length(instring)-1))
total_lines = total_lines + 1
call new_page
end
else
do
if count >= lpp then call new_page
else nop
call writeln('out',instring)
count = count + 1
total_lines = total_lines + 1
end
end
else call writeln('out',instring)
end
if count_lines then
do
call page_minder('0A'X || 'Total records in file = ' || total_rcds || ' Total lines printed = ' || total_lines+2 || ' Seconds to print = ' || time('E'))
if (count > 0) & (substr(p_no,1,1) = 'b') then call new_page
end
else call writeln('out','Total records in file = ' || total_rcds || ' Seconds to print = ' || time('E'))
call close(prntfile)
call close('out')
if (index(upper(file2print),"$$M!SPOOL/$$") > 0) then
'delete' file2print || " Quiet"
end
return
look4spec_char: procedure expose cc schar rchar
spec_char = index(cc,schar)
do while(spec_char > 0)
if (spec_char + 2) > length(cc) then cc_rest = ""
else cc_rest = substr(cc,spec_char+2)
if spec_char = 1 then cc = ""
else cc = substr(cc,1,spec_char-1)
cc = cc || rchar || cc_rest
spec_char = index(cc,schar)
end
return
page_minder: procedure expose count lpp total_lines p_no page
parse arg instring
if right(instring,1) = '0C'X then
do
if count >= lpp then call new_page
call writeln('out',left(instring,length(instring)-1))
total_lines = total_lines + 1
call new_page
return
end
if count >= lpp then call new_page
call writeln('out',instring)
count = count + 1
total_lines = total_lines + 1
return
new_page: procedure expose count p_no page total_lines
ff = '0C'X
if p_no ~= 'null' then
do
page = page + 1
t_or_b = substr(p_no,1,1)
if page = 0 then
if t_or_b = 'b' then
do
call writech('out',ff)
return
end
else page = 1
else nop
total_lines = total_lines + 2
if t_or_b = 't' then call writech('out',ff)
else call writeln('out',' ')
where = substr(p_no,2,1)
page_text = 'Page ' || page
select
when where = 'l' then call writeln('out',page_text)
when where = 'c' then call writeln('out',center(page_text,80))
when where = 'r' then call writeln('out',copies(' ',80-length(page_text)) || page_text)
end
if t_or_b = 't' then
do
count = 2
call writeln('out',' ')
end
else
do
count = 0
call writech('out',ff)
end
end
else
do
call writech('out',ff)
count = 0
end
return
/*----------------------------- End REXX Source -----------------------------*/