[comp.lang.rexx] Useful rexx script

cmcmanis%pepper@Sun.COM (Chuck McManis) (09/16/89)

This is a useful REXX script I've been using to print out files. If 
you have WShell (Bill Hawes replacement for the Amiga shell) you can
put it in rexx: and just type printfile <filename> from the prompt.
Otherwise, you will need to type rx "printfile filename" to use it.

--Chuck

/* Rexx script */
/* printfile.rexx will print a text file on the printer with headers */
say "Printing File" WORD(ARG(1),1)
if open('Source',WORD(ARG(1),1), 'Read') ~= 1 then do
	say "File not found."
	exit
	end

outfile = "PRT:"
if WORDS(Arg(1)) > 1 then outfile = Words(ARG(1),2)

if open('Printer',outfile,'Write') ~= 1 then do
	say "Can't open destination."
	exit
	end
i = 0
page = 1
do while EOF('Source') ~= 1
	if i = 0 then do
		e = writeln('Printer','0c'x);
		e = writeln('Printer', ARG(1) "      Page " page);
		e = writeln('Printer', '0a0a0a'X);
		page = page + 1
	end
	line = Readln('Source')
	e = writeln('Printer', line)
	i = (i + 1) // 50
end

--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.
"If I were driving a Macintosh, I'd have to stop before I could turn the wheel."