#

# no user defined shorthands
unalias *

set sedfile=/usr/lib/p400.sed

set xoff=20
set yoff=20
set lxpand=2
set txpand=2
set copy=1
set pagel=66
set width=80
set language=0
set quer=0

set nqopts=()

# somebody hating banners may set NOBANNER
if ( $?NOBANNER ) set argv=( -nb $argv )

while ($#argv)
    switch ($argv[1])
       case -nb :
	  alias /lib/p400banner echo
	  breaksw;
       case -q :
	   set yoff=274
	   set xoff=26
	   set lxpand=1
	   set txpand=2
	   set width=132
	   set quer=1
	   breaksw
       case -l :
	   shift argv
	   set pagel=$argv[1]
	   breaksw
       case -w :
	   shift argv
	   set width=$argv[1]
	   breaksw
       case -x :
	   shift argv
	   set xoff=$argv[1]
	   breaksw
       case -y :
	   shift argv
	   set yoff=$argv[1]
	   breaksw
       case -s :
	   shift argv
	   set txpand=$argv[1]
	   set lxpand=$argv[1]
	   breaksw
       case -c :
	   shift argv
	   set copy=$argv[1]
	   breaksw
       case -t :
	   shift argv
	   set language=$argv[1]
	   breaksw
       case -m : 
	   set nqopts=($nqopts -m)
	   breaksw
       case -Q : 
	   shift argv
	   set nqopts=($nqopts -q $argv[1])
	   breaksw
       case -nq :
	   shift argv
	   set nqopts=($nqopts $argv[1])
	   breaksw
       case -* :
	   set ratte=$0
	   echo2 $ratte:t\: unknown option $argv[1]
	   exit 1
	   breaksw
       default:
	   break
    endsw
    shift argv
end



if ( ! $quer ) then
    ( /lib/p400banner $argv; echo -n "#[;#NC$copy;#FO'ANTIC15.N.8.P';#LA$language;#LD4.;#EL$lxpand;#ET$txpand;#PX$xoff.;#PY$yoff.;#M0.;#CR;#NL$pagel;#DF1;" ; \
    /usr/bin/expand $argv | cut -c1-$width | /usr/bin/sed -f $sedfile ; \
    echo -n '#DF0;#];' ) | /usr/bin/nq -nb -q text:1 $nqopts
else
    ( /lib/p400banner $argv; echo -n "#[;#NC$copy;#FO'ANTIC15.N.8.L';#PRL;#LA$language;#LD4.;#EL$lxpand;#ET$txpand;#PY$yoff.;#PX$xoff.;#M0.;#DF1;" ; \
    /usr/bin/expand $argv | cut -c1-$width | /usr/bin/sed -f $sedfile ; \
    echo -n '#DF0;#];' ) | /usr/bin/nq -nb -q text:1 $nqopts
endif
