#!/bin/csh -f
# This program prints a Magic file on an Imagen using stipple patterns.
#
# Source: CalTech.   Modified at ISI by DBooth 7/20/85.
#                    Modified at UMd by N Naclerio 7/14/86 to use qpr.
#
# Local variables:
#   printerarg	-- -Pprinter argument, using $MAGPLOT_PRINTER default.
#   lprargs		-- All other -* options, simply passed on to lpr.
#   laserargs       -- Flags passed to laserplot program.
#   files		-- File name arguments.

# Set printer name variable, and separate file names from lpr options.

set printerarg = (-q ee-imp)
set lprargs = ( )
set files = ( )
set laserarg = ( )
foreach i ( $argv )
    switch ( $i )
    case -q*:
	set printerarg = $i
	breaksw
    case -l:
	set laserarg = ( $laserarg $i )
	breaksw
    case -g:
	set laserarg = ( $laserarg $i )
	breaksw
    case -*:
	set lprargs = ( $lprargs $i )
	breaksw
    default:
	set files = ( $files $i )
	breaksw
    endsw
end

# Process each file name if there are any.

if ( $#files < 1 ) then
    echo 'Usage: magplot [ -q queue ] [ -l ] magicfile . . '
else
    foreach i ( $files )
	if ( -r $i || -r $i.mag) then
	    echo -n Processing $i ...
	    mtopic $i \
		| laserplot $laserarg -j $i -S -h\
		| qpr $printerarg $lprargs
	    echo 'done.'
	else
	    echo Could not open $i
	endif
    end
endif
