c 1996,8,30
	character a*128,b*196,c*70,d*70,ft*24,fdate*24,f1*40,cr*1
	byte init1(9),init2(24),init3(23),iend(5)
	data init1/32,32,27,'E',27,'&','a','0','L'/	! reset & left margin
	data init2/27,'(','s','1','2','.','0','0','h',	! default
     *                '1','0','.','0','v','3','T',	! font
     *             27,'&','l','6','d','6','2','F'/	! line gap
	data init3/27,'(','s','1','6','.','6','7','h',	! samll font
     *                '8','.','5','v','0','T',		! font
     *             27,'&','l','8','d','8','2','F'/	! line gap
	data  iend/27,'&','l','0','H'/			! eject paper
	cr=char(13)
	n=iargc()
	if(n.eq.0)then
	write(*,*)'HP 2p Laser_printer (create by Jiang 1990,12,17)'
	write(*,*)'usage: hp2p [-te#] file1 file2 ... '
	write(*,*)'    t: title;  e: small_font;  #: 0~9 left margin)'
	stop
	endif
	call getenv('HOME',f1)
	f1=f1(1:lnblnk(f1))//'/daemon.page'
	k1=1
	ipage=62
	call getarg(k1,a)
	if(a(1:1).eq.'-')then
	k1=k1+1
	if(a(2:2).eq.'t'.or.a(3:3).eq.'t'.or.a(4:4).eq.'t')ipage=60
	if(a(2:2).eq.'e'.or.a(3:3).eq.'e'.or.a(4:4).eq.'e')ipage=ipage+20
	do 99 i=2,4
	k=ichar(a(i:i))
99	if(k.lt.58.and.k.gt.48)init1(8)=k
	endif		
	do 100 k=k1,n
	call getarg(k,a)
	open(1,file=a,status='old',iostat=ierr)
	if(ierr.ne.0)write(*,*)'cannot access ',a(1:30)
	if(ierr.ne.0)goto 100
	call unlink(f1)
	open(2,file=f1,status='new')
	call getenv('HOST',b)
	call getenv('PWD',c)
	d=b(1:lnblnk(b))//':'//c
	c=d(1:lnblnk(d))//'/'//a
	if(ipage.lt.70)write(2,'(33a1,$)')init1,init2
	if(ipage.gt.70)write(2,'(32a1,$)')init1,init3
	i=0
	ip=0
10	i=i+1
	read(1,'(a)',end=20)a
	if(mod(i,ipage).eq.1)then
	ip=ip+1
	ft=fdate()
	if(ipage.eq.60)write(2,"(2a,4x,'page',i4/)")cr,c(1:40)//ft,ip
	if(ipage.eq.80)write(2,"(2a,9x,'page',i5/)")cr,c(1:60)//ft,ip
	endif
	j2=0
	do 30 j=1,lnblnk(a)
	j2=j2+1
	if(ichar(a(j:j)).ne.9)then
	b(j2:j2)=a(j:j)
		else
	j3=j2+7-mod(j2-1,8)
	b(j2:j3)=' '
	j2=j3
		endif
30	continue
	write(2,"(2a)")cr,b(1:j2)
	goto 10
20	write(2,'(5a1,$)')iend
	close(2)
	close(1)
	a='lpr -Php '//f1
	write(*,*)a
	call system(a)
	write(*,*)c(1:40),ip,' pages'
100	continue
	call unlink(f1)
	end
