	SUBROUTINE FRMEDT(INLIN,LEND)
C COPYRIGHT 1984 GLENN AND MARY EVERHART
C FORMULA EDIT TO FIND AND EDIT FORMULAS OF FORM
C	{VAR
C AND REPLACE THE VARIABLE SPEC BY FORMULA FOR THAT VARIABLE
	INCLUDE 'VKLUGPRM.FTN'
	LOGICAL*1 INLIN(110),WRK1(120),WRK2(128)
	INTEGER*2 LEND
	LCNT=0
1000	IF(LCNT.GT.10)RETURN
	I1=INDEX(INLIN,'{')
	IF(I1.LE.0.OR.I1.GT.70)RETURN
	IF(INLIN(I1).NE.'{')RETURN
C ONLY ALLOW IF THERE IS A { CHAR THERE
	LO=I1+1
	IHI=LO+25
	CALL VARSCN(INLIN,LO,IHI,LSTCHR,ID1,ID2,IVLD)
	IF(IVLD.LE.0)RETURN
	DO 11 N1=1,120
11	WRK1(N1)=0
C HERE HAVE A VALID CONSTRUCT SO REPLACE IT
C (ONLY ONE PER LINE THIS TIME ROUND)
	IRX=(ID2-1)*RRW+ID1
C COPY FIRST PART OF FORMULA TO WORK ARRAY
	LO=I1-1
	IHI=0
	IF(LO.LE.0)GOTO 10
	DO 1 N1=1,LO
	IHI=N1
	WRK1(IHI)=INLIN(N1)
1	CONTINUE
10	CONTINUE
	IHI=IHI+1
	CALL WRKFIL(IRX,WRK2,0)
C WRKFIL READS THE FORMULA INTO WRK2. NEXT FIND END OF TEXT
	DO 2 N1=1,110
	LO=111-N1
	IF(WRK2(LO).GT.32)GOTO 3
2	CONTINUE
3	CONTINUE
C LO NOW IS LENGTH OF FORMULA
	DO 4 N1=1,LO
	WRK1(IHI)=WRK2(N1)
	IF(IHI.LT.110)IHI=IHI+1
4	CONTINUE
C TACK ON ANY MORE TEXT
C RELY ON INLIN BEING 110 CHARS LONG
	DO 5 N1=LSTCHR,110
	WRK1(IHI)=INLIN(N1)
	IF(IHI.LT.110)IHI=IHI+1
5	CONTINUE
C NOW COPY 110 CHARS BACK TO INLIN
	DO 6 N1=1,110
6	INLIN(N1)=WRK1(N1)
	DO 7 N1=1,110
	LO=111-N1
	IF(INLIN(LO).GT.32)GOTO 8
C	INLIN(LO)=32
7	CONTINUE
8	LEND=LO
	LCNT=LCNT+1
	GOTO 1000
C KEEP LOOKING & RECURSING BUT IMPOSE LIMIT
C	RETURN
	END
