Trailing-Edge - PDP-10 Archives - steco_19840320_1er_E35 - 10,5676/teco/macros/runcon.tco
There is 1 other file named runcon.tco in the archive. Click here to see a list.
!;RUNCON -- Table of Contents Generator for RUNOFF output files	!
!;Author: C. Dawson -- Univ. of Texas at Austin -- 27-Feb-79	!
!;Editor:							!
!;	R. McQueen -- Stevens Institute of Technology		!
!;This macro will currently only handle RUNOFF documents which	!
!;have made use of .HL command, but not the .CHAPTER command.	!
!;Also, it uses absolute page numbers rather than numbers	!
!;appearing in the file itself.					!
!;To use, type:							!
!;	.R TECO							!
!;	*EIRUNCON$$						!
!;The table of contents will be placed in Q-register C, enabling!
!;you to edit the RUNOFF source file and place the table within	!
!;a literal block, for example.					!
	EOU7 3EO$
	 ^A"?" for help^A		!;Type greeting!
!;Read in a file name!
!start!	HK I:ER$ .U1
File: ^A
!getch!	^TUt
	Qt-^o77 "E ^A
Type the file name of the RUNOFF output file that you want
a table of contents for.  End with a <CR>.^A Ostart$ '
	Qt-^o10 "E Q1-."E Ostart$ ' ^A ^A :^o10,1^T -D Ogetch$ '
	Qt-^o177"E Q1-."E Ostart$ ' .-1,.T          -D Ogetch$ '
	Qt-^o25 "E ^A^U^A :^o15,1^T :^o12,1^T          Ostart$ '
	Qt-^o22 "E ^A^A   :^o15,1^T :^o12,1^T Q1,.T    Ogetch$ '
	Qt-^o15 "N QtI$ Ogetch$ '
	HXt Mt"F ^AFile not found.^A Ostart$ '
	^A[Working] ^A
	HK HXc 0Uy
			!;Search for a line that looks like a .HEADER LEVEL!
	 :S^E<12>^E[^ES,^Ed]$		!;LF (<blanks> or digit)!
	 "S 0A-32"E 1A"D Ook$' Oloop$'	!;If <blanks>, make sure digit follows!
!ok!	    <.,.+1s^Ed$;>		!;digits!
	    :.,.+2s.^Ed$		!;period digit!
	    "S <.,.+1s^E[^Ed,.]$;>	!;periods & digits!
	       :.,.+3s  ^N $		!;blank blank non-blank!
	       "S			!;We have found a title!
	          0L Xa .U1 ZJ ZU5 Ga   !;Move line to the end of the buffer!
	          Q5J S.$ .U6 Q5J 4-Q6+Q5<I $>	!;Put in leading spaces!
	          S.$ S  $ 10-.+Q5<I $>	!;Spaces after sec. number!
	          0U2 <.,Q5S.$; R %2>	!;Count levels!
		  S.$ S  $ Q2*2<I $>	!;Indent accordingly!
		  Q2-1"G 		!;If HL 3 or greater...!
		   :S - $"S 3R K	!;Remove all text after a "-"!
			    13I$ 10I$''	!;Restore crlf!
	          Q5J :S.0   $		!;See if major section!
	          "S -3D Q5J 13I$ 10I$'	!;Blank line before major sections!
	          .U2 L 2R .-Q2Um	!;Get length of line!
	          Qm-66"G 66-QmD 66Um '	!;Truncate long lines!
	          Qm/2*2-Qm"NI.$ %m'	!;If odd length, add a dot!
		  66-Qm/2<I .$>		!;Dots....!
	          QxU3			!;Get page number!
		  0U2 Q3-9"G %2
		      Q3-99"G %2
		      Q3-999"G %2'''	!;Count number of digits!
		  3-Q2<I $> Q3\		!;Insert page number!
		  Q5J Gc Q5,ZXc Q5,ZK Q1J   !;Append line to Q-reg C!
!;Read in a page!
	Qx-Qy"N ^o40,Qx= ^A^A QxUy '	!;Type page number to show progress!
	^N"E EY <-1-^N; -1-^E; A>	!;Read in entire page!
	^YUx ^E"E %x'			!;Get page number. Add 1 if no FF read!
	     Oloop$			!;Loop back till done!
	  '				!;We're finished!
	HK Q7EO ]7]z]y]x]t]m]a]6]5]4]3]2]1 EC
[Finished. Table of Contents is in Q-register C]