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' PARAMETER NMNMS=18 PARAMETER CUP=1 C ADD LOGICAL NAMES IN THE FOLLOWING FASHION, TO BE MANIPULATED C HERE ALONE: C C STORE LOGICAL NAMES, UP TO 16 CHARS, HERE IN AN ARRAY WITH C DESIRED ID1,ID2 VALUES OF CELLS TO LOAD. WHERE A {NAME IS SEEN, C REPLACE WITH DESIRED CELL ADDRESS. C TO DEFINE LOGICAL NAMES, LOOK FOR = AFTER A NAME. IF = IS SEEN C AFTER THE { CHARACTER, ASSUME IT'S A LINE OF FORM {SALES=AA0 C (OR {SALES=00 TO DEASSIGN) AND STORE THE NAME. UP TO THE USER C TO PUT THE DESIRED FORMULA IN AS HE LIKES. MAY USE A TEST STMT C IF DESIRED. D LOGICAL*1 NAMARY(20,NMNMS) C ALLOW AS MANY NAMES AS THERE ARE ROWS... ARBITRARY... D INTEGER*2 NAMNUM(10,NMNMS) D EQUIVALENCE(NAMARY(1,1),NAMNUM(1,1)) C NAMNUM(9,NMNMS) AND NAMNUM(10,NMNMS) ARE RRW AND RCL C STORAGE. NAMARY(1-18,NMNMS) STORES NAME ASCII TEXT (POSSIBLY C NULL TERMINATED). FIND CELLS VIA LINEAR SEARCH. D INTEGER*2 NAMMAX C NAMMAX IS MAX DIM OF NAMARY THAT'S FILLED IN. D COMMON/NMNMNM/NAMARY,NAMMAX LOGICAL*1 INLIN(110),WRK1(120),WRK2(128) INTEGER*2 LEND C DATA NAMMAX/0/ LCNT=0 1000 IF(LCNT.GT.20)RETURN I1=INDEX(INLIN,'{') IF(I1.LE.0.OR.I1.GT.70)RETURN IF(INLIN(I1).NE.'{')RETURN D I2=INDEX(INLIN,'=') D IF(I2.LE.0.OR.I2.LT.I1.OR.I2.GT.70.OR.INLIN(I2) D 1 .NE.'=')GOTO 5400 D IF((I2-I1).LE.1)GOTO 5400 DC HERE SEE AN = SIGN AFTER A {VAR STRING. ATTEMPT TO EVALUATE. DC GUARANTEED AT LEAST 1 CHARACTER OF NAME. D I3=MIN0((I2-I1-1),16) Dc check if * seen ( text would then be {*= ) for printout Dc of symbol table D IF(INLIN(I1+1).NE.'*')GOTO 5600 D IF(NAMMAX.LE.0)GOTO 5600 D CALL UVT100(CUP,LCMDR,1) D CALL UVT100(12,2,0) DC ERASE LINE D WRITE(6,5601) D5601 FORMAT('Output File:') D read(5,5602)(wrk1(II),II=1,80) D5602 format(110a1) D DO 5603 N=1,78 D NN=79-N D IF(WRK1(NN).GT.32)GOTO 5604 D WRK1(NN)=0 D5603 CONTINUE D5604 CONTINUE D CLOSE(UNIT=8) D CALL ASSIGN(8,WRK1) DC OPEN OUTPUT FOR WRITE DC THEN DUMP SYMBOLS THERE DC SYMBOL TABLE DUMP CAN BE SAVED ANYWHERE AND REENTERED AS DC ASSIGNMENT STMTS. D WRK1(1)='{' D DO 5607 N=2,110 D5607 WRK1(N)=0 D WRK1(18)='=' D DO 5605 N=1,NAMMAX D IF(NAMNUM(9,N)+NAMNUM(10,N).LE.0)GOTO 5605 D DO 5608 NN=1,16 D5608 WRK1(NN+1)=NAMARY(NN,N) D CALL IN2AS(NAMNUM(9,N),WRK1(19)) D ENCODE(3,5606,WRK1(23),ERR=5419)NAMNUM(10,N)-1 D5606 FORMAT(I3) D K=3 D WRK2(1)='T' D WRK2(2)='E' D WRK2(3)=' ' D DO 5609 KK=1,106 D I4=WRK1(KK) D IF(I4.LE.32)GOTO 5609 D K=K+1 D WRK2(K)=I4 D5609 CONTINUE DC WRITE OUT DEFINITIONS AS IF THEY WERE ASSIGMNENT STMTS. D WRITE(8,5610)(WRK2(KK),KK=1,K) D5610 FORMAT(110A1) D5605 CONTINUE D CLOSE(UNIT=8) D GOTO 5419 D5600 CONTINUE D LO=I2+1 D IHI=LO+25 D CALL VARSCN(INLIN,LO,IHI,LSTCHR,ID1,ID2,IVLD) DC IF IVLD=0 ASSUME WE'RE UNDEFINING THE SYMBOL D IF(IVLD.GT.0)GOTO 5402 DC INVALID SYMBOL ... UNDEFINE STRING D DO 5403 I4=1,NAMMAX D DO 5404 I5=1,I3 D IF(INLIN(I1+I5).NE.NAMARY(I5,I4))GOTO 5403 D5404 CONTINUE DC GOT IT IF WE FALL THRU D NAMNUM(9,I4)=0 D NAMNUM(10,I4)=0 D DO 5443 I5=1,16 D5443 NAMARY(I5,I4)=0 DC ZERO THE ELEMENT DEFINITION AND FORGET IT... D5403 CONTINUE D GOTO 5419 D5402 CONTINUE DC VALID ARRAY ELEMENT, DEFINE IT. D IF(NAMMAX.LE.0)GOTO 5406 D DO 5405 I4=1,NAMMAX D IF(NAMNUM(9,I4)+NAMNUM(10,I4).EQ.0)GOTO 5410 D5405 CONTINUE D GOTO 5406 D5410 CONTINUE DC GOT IT IF WE FALL HERE D NAMNUM(9,I4)=ID1 D NAMNUM(10,I4)=ID2 DC ZERO THE ELEMENT DEFINITION AND FORGET IT... D GOTO 5407 D5406 CONTINUE D IF(NAMMAX.LT.0)NAMMAX=0 D NAMMAX=MIN0(NAMMAX+1,NMNMS) D NAMNUM(9,NAMMAX)=ID1 D NAMNUM(10,NAMMAX)=ID2 DC NOW SAVE THE SYMBOL NAME D I4=NAMMAX D5407 CONTINUE DC ZERO CHARACTERS FIRST, THEN FILL IN D DO 5409 I5=1,16 D5409 NAMARY(I5,I4)=0 D DO 5408 I5=1,I3 D NAMARY(I5,I4)=INLIN(I1+I5) D5408 CONTINUE DC NO FURTHER PROCESSING IF WE DID ANY DEFINITION... JUST EXIT D5419 INLIN(1)='%' D DO 5421 I5=2,110 D5421 INLIN(I5)=0 DC JUST NULL OUT THE LINE IF A DEFINITION. KEEPS FROM FURTHER DC ERRORS... D RETURN D5400 CONTINUE C NOW THAT DEFINITIONS ARE TAKEN CARE OF (IF ANY) C HANDLE SYMBOLIC SEARCHES D IF(NAMMAX.LE.0)GOTO 5505 D LSTCHR=I1+1 D DO 5501 I4=1,NAMMAX D DO 5502 I5=1,16 D IF(NAMARY(I5,I4).LE.47)GOTO 5502 D IF(INLIN(I1+I5).LE.47)GOTO 5502 D LSTCHR=I1+I5+1 D IF(INLIN(I1+I5).NE.NAMARY(I5,I4))GOTO 5501 DC ALLOW MATCH PROVIDED THAT AT LEAST 1ST CHAR IS LEGAL. DC IF(NAMARY(1,I4).GE.48.AND.NAMARY(I5,I4).LE.47)GOTO 5560 D5502 CONTINUE D5560 CONTINUE DC IF WE FALL THRU WE HAVE A MATCH D ID1=NAMNUM(9,I4) D ID2=NAMNUM(10,I4) DC LAST CHECK: BE SURE WE AREN'T GIVING A DELETED SYMBOL. D IF((ID1+ID2).GT.0)GOTO 5500 D5501 CONTINUE D5505 CONTINUE DC 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 D5500 CONTINUE 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) C IRX=(ID2-1)*RRW+ID1 CALL REFLEC(ID2,ID1,IRX) 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