	PROGRAM SEARCH
C
	BYTE BLOK(512),KEYW(82,100),PRK(12),PRF(12),FILNAM(80),PRT(2),X
	DIMENSION ISPEC(39),IOPT(4,7),IDEFXT(4)
	DATA IOPT /65,3*0,70,3*0,75,3*0,80,3*0,84,3*0,83,3*0,69,3*0/
	DATA PRK /'K','e','y','w','o','r','d',' ','?',' ',"200,0/
	DATA PRF /'F','i','l','e','n','a','m','e',' ','?',' ',"200/
	DATA PRT /'*',"200/
	DATA IDEFXT /3RDSK,3*0/
	DATA RNULL /0./
	EQUIVALENCE (BLOK(511),RNULL)
C
1	FORMAT('+ Testblock = ',O6)
2	FORMAT('+Block number: ',O6,8(/X,64A1)//)
3	FORMAT('+Probable number of printable ASCII blocks = ',I7,'.'/)
4	FORMAT('+?SEARCH-F-No free channel available'/)
5	FORMAT('+?SEARCH-F-Conflicting options'/)
6	FORMAT('+?SEARCH-F-Unable to open file'/)
7	FORMAT('+?SEARCH-F-Lookup failed'/)
C
	ICHAN=IGETC()
	IF (ICHAN.LT.0) GOTO 120
C
10	JBLOK=0
	CALL ICSI(ISPEC,IDEFXT,,IOPT,7)
	IF (IOPT(2,2).AND.IOPT(2,4)) GOTO 90
	IF (IOPT(2,2).AND.IOPT(2,5)) GOTO 90
	IF (IOPT(2,4).AND.IOPT(2,5)) GOTO 90
C
	ISTART=0
	IEND=0
	IF (IOPT(2,6).EQ.2) ISTART=IOPT(4,6)
	IF (IOPT(2,7).EQ.2) IEND  =IOPT(4,7)
C
	IPERC=75
	IF (IOPT(2,3).NE.0) IPERC=0
	IF (IOPT(2,1).EQ.2) IPERC=IOPT(4,1)
C
	LUN=0
	IF (IOPT(2,2).NE.0) LUN=2
	IF (IOPT(2,4).NE.0) LUN=6
	IF (IOPT(2,5).NE.0) LUN=7
	IF (LUN.EQ.2) CALL GTLIN(FILNAM,PRF)
	IF (LUN.EQ.2) OPEN (UNIT=LUN,NAME=FILNAM,ERR=100,
	*			CARRIAGECONTROL='FORTRAN')
C
	IK=1
	IF (IOPT(2,3).EQ.0) GOTO 30
	DO 20, IK=1,100
	  CALL GTLIN(KEYW(1,IK),PRK)
	  IF (KEYW(1,IK).EQ.0) GOTO 30
20	CONTINUE
30	IK=IK-1
CC
	NBLOK=LOOKUP(ICHAN,ISPEC(16))-1
	IF (NBLOK.LT.-1) GOTO 110
	IF (NBLOK.NE.-1.AND.(NBLOK.LT.IEND.OR.IEND.EQ.0)) IEND=NBLOK
C
	DO 70, IBLOK=ISTART,IEND
	  TYPE 1,IBLOK+0
	  IF (IREADW(256,BLOK,IBLOK+0,ICHAN).LT.0) GOTO 80
	  IASC=0
	  INONZ=0
C
	  DO 40, IBYTE=1,512
	    X=BLOK(IBYTE)
	    IF (X.NE. 0) INONZ=INONZ+1
	    IF (X.GE.' '.AND.X.LE.'~') IASC =IASC +1
	    IF (X.EQ.9.OR.X.EQ.10.OR.X.EQ.13) IASC=IASC+1
	    IF (X.LT.' '.OR. X.GT.'~') BLOK(IBYTE)='.'
40	  CONTINUE
C
	  IF (INONZ.EQ.0) GOTO 70
	  IF (((FLOAT(IASC))/FLOAT(INONZ)).LT.(1E-2*FLOAT(IPERC))) GOTO 70
	  JBLOK=JBLOK+1
	  IF (LUN.EQ.0) GOTO 70
C
	  IF (IK.EQ.0) GOTO 60
	  DO 50, JK=1,IK
	    IF (INDEX(BLOK,KEYW(1,JK)).NE.0) GOTO 60
50	  CONTINUE
	  GOTO 70
C
60	  WRITE(LUN,2) IBLOK+0,BLOK
70	CONTINUE
C
80	TYPE 3,JBLOK
	IF (LUN.EQ.2) CLOSE(UNIT=LUN)
	CALL CLOSEC(ICHAN)
	GOTO 10
C
90	TYPE 5
	GOTO 10
100	TYPE 6
	GOTO 10
110	TYPE 7
	GOTO 10
120	TYPE 4
	CALL EXIT
	END
