PROGRAM INCL c Version 4.03 08-Mar-84 Skip Comment lines c Version 4.02 10-Dec-83 c --------------------------------------------------------- c FORTRAN/RT pre-processor to simulate an INCLUDE statement c c Original program PFTRAN written by Dr. EDER, TH Darmstadt c Extended to handle multiple include statements by H. PAGE c c Chain entry added. c B. Kup, TH Darmstadt. c c Extended for compatibility with other INCLUDE processors, c which use a different syntax (file name in single quotes), c to support both flavors if INCLUDE. c B. Kup, TH Darmstadt. c c INCLUDE 'filnam.ext' c % include filnam.ext c --------------------------------------------------------- c Integer chaind ! Chain flag Byte prompt(2),line(134) Byte work1(134),work2(134) Byte in(16),out(16),in1(16) Data prompt /'*',"200/ Data Version/04.03/ c c Look if this is a chain call c Call RCHAIN(chaind,line,8) If (chaind) Goto 3 c c Else get a command line c (future version should call the CSI, as this version does no allow c other devices than DK.) c 1 Call GTLIN(line,prompt) If (len(line).ne.0) goto 3 Type 2,Version ! traditional 'Hello' 2 Format ('+INCL V'F5.2/) Goto 1 c 3 Call CONCAT(line,'.FOR',in) ! construct file names Call CONCAT(line,'.TMP',out) c If (chaind) Type 4,(in(j),j=1,len(in)) ! Chained 'Hello' 4 Format ('+INCL: '15A1/) c D Type 300,(in(j),j=1,len(in)) D Type 300,(out(j),j=1,len(out)) D 300 Format(' -'15a1) c c Now open the input & output file c Open (Access='SEQUENTIAL',Form='FORMATTED', &Unit=1,Name=in,Type='OLD',Err=3000) Open (Access='SEQUENTIAL',Form='FORMATTED', &Unit=2,Name=out,Type='NEW',InitialSize=-1,Err=6) Goto 5 c 6 Call CONCAT ('TMP:',out,out) Open (ACCESS='SEQUENTIAL',FORM='FORMATTED', &UNIT=2,NAME=out,TYPE='NEW',InitialSize=-1,Err=5000) c 5 Continue line(1)=0 Call GETSTR(1,line,132,ierr) ! Get a line D Type *,' ierr = ',ierr If(ierr.Eq.255) Goto 1000 ! EOF found c D Type 310,(line(j),j=1,len(line)) D 310 Format(' inline -',150a1) D Type 309,line(1) D 309 Format(' 1st char -'a1) c c Start looking for % in the 1st column or an INCLUDE statement c ccc IF ((line(1).eq.'C').or.(line(1).eq.'c')) Goto 500 !Copy If ((line(1).or.' ').eq.'c') Goto 5 !V04.03 If (line(1).eq.'%') Goto 8 i1 = INDEX(line,'Include') If (i1.ne.0) Goto 9 ! if INCLUDE found i1 = INDEX(line,'INCLUDE') If (i1.ne.0) Goto 9 i1 = INDEX(line,'include') If (i1.ne.0) Goto 9 Goto 500 ! No INCLUDE c 8 i1 = INDEX(line,'include') If (i1.ne.0) Goto 9 i1 = INDEX(line,'INCLUDE') If(i1.eq.0) Goto 3999 c Else 9 Do 10 i = i1 + 8,900 If(line(i).ne.' '.and.line(i).ne."11) goto 20 10 Continue c 20 istart = i If (line(i).eq.'''') istart=istart+1 D Type *,' istart = ',istart Do 30 i =istart,100 If(line(i).eq.' '.or.line(i).eq.0.or.line(i).eq.'''' 1 .or.line(i).eq.'!') goto 40 30 Continue C 40 ilen = i - istart D Type *,' ilen = ',ilen Call SUBSTR(line,in1,istart,ilen) !extract INCLUDE file name c Open (FORM='FORMATTED',ACCESS='SEQUENTIAL', 1UNIT=3,NAME=in1,TYPE='OLD',ERR=4000) Type 315,(in1(j),j=1,INDEX(in1,'.')-1) 315 Format($'+['6A1:) Type 316 316 Format('+]'/) c 45 Call GETSTR(3,work2,132,ieof) D Type *,' ierr = ',ierr If (ieof) Goto 70 ! EOF c If ((WORK2(1).or.' ').eq.'c') Goto 45 !V04.03 Call TRIM(work2) Write(2,212)(WORK2(J),J=1,LEN(work2)) 212 Format(132A1) Goto 45 c 70 Close (UNIT=3) Goto 5 c c Copy current line to output file c 500 Call TRIM(line) Write(2,212)(line(j),j=1,len(line)) Goto 5 c c c 1000 Close (UNIT=1) Close (UNIT=2) Goto 9000 c 3000 Type 3010 3010 Format('+?INCL-F-Unable to open input file'/) Goto 9999 c 4000 Type 4010,(in1(j),j=1,len(in1)) 4010 Format('+?INCL-F-Unable to open include file - ',15a1/) Goto 9999 c 5000 Type 5010 5010 Format('+?INCL-F-No room for output'/) Goto 9999 c 3999 Type 4100 4100 Format('+?INCL-F-Illegal include statement'/) c 9999 Call IPOKEB("53,4) ! Set ERROR in User Err Byte 9000 Call EXIT END