	PROGRAM BINARY
	INTEGER*2 ASCII(128),ICNT,IBASE,IRAST,ILEN
	BYTE X(5000),Y(5000)
	CHARACTER NAME*30
100	WRITE(5,'('' FILE: '',$)')
	READ(5,'(A30)')NAME
	IF(NAME.EQ.'STOP')STOP
	OPEN(1,FILE=NAME,STATUS='OLD')
	OPEN(2,FILE=NAME,STATUS='NEW',FORM='UNFORMATTED')
	READ(1,987)ICNT,IBASE,IRAST
987	FORMAT(1X,I2,2I4)
	IF(ICNT.EQ.99)THEN
	READ(1,985)(ASCII(IJ),IJ=1,128)
	ILEN=ASCII(128)
	ELSE
	READ(1,985)(ASCII(IJ),IJ=1,ICNT+1)
	ILEN=ASCII(ICNT+1)
	DO 1010 IJ=ICNT+1,128
1010	ASCII(IJ)=1
	ENDIF
985	FORMAT(1X,20I4)
	READ(1,984)(X(IJ),IJ=1,ILEN)
	READ(1,984)(Y(IJ),IJ=1,ILEN)
984	FORMAT(1X,40I2)
	CLOSE(1)
	WRITE(2)ICNT,IBASE,IRAST,ILEN
	WRITE(2)(ASCII(I),I=1,127)
	WRITE(2)(X(I),I=1,ILEN)
	WRITE(2)(Y(I),I=1,ILEN)
	CLOSE(2)
	GOTO 100
	END
