5 GOSUB 400 \ REM init stuff
10 R0=1
20 ON R0 GO TO 21,500,690,850
21 REM
30 PRINT 'File In'; \ LINPUT F0$ \ IF POS(F0$,'.',1)=0 THEN F0$=F0$+'.MAC'
40 PRINT 'File Out'; \ LINPUT F1$ \ IF POS(F1$,'.',1)=0 THEN F1$=F1$+'.LST'
45 R9$=SEG$(F0$,1,POS(F0$,'.',1)-1)
50 IF SEG$(F1$,1,1)='.' THEN F1$=R9$+F1$
70 PRINT 'Suppress Lines'; \ LINPUT R$ \ IF R$='Y' THEN O1=0
72 IF R$='y' THEN O1=0
75 PRINT F1$;'=';F0$
77 GOSUB 460 \ REM more init stuff
80 OPEN F0$ FOR INPUT AS FILE #1
90 OPEN F1$ FOR OUTPUT AS FILE #2
100 IF END #1 GO TO 2000
110 LINPUT #1,A$
115 IF SEG$(A$,1,1)=';' THEN L2$=A$ \ GO TO 130
117 IF SEG$(A$,1,1)='/' THEN L2$=A$ \ GO TO 130
120 GOSUB 690 \ GOSUB 500 \ GOSUB 850
130 PRINT #L9,P$+L2$ \ P$=""
140 GO TO 100
200 REM	a$	line read
210 REM	b$	back tokens
220 REM	F0$	file in
230 REM	f$	forward tokens
240 REM	f1$ 	file out
250 REM	i	indent factor
260 REM	i$	indenting chars
270 REM	i1$	char 1 of i$
280 REM	i2$	i1$+'       '
290 REM	l	level counter
300 REM	l$	label
310 REM	l1	line #
315 REM	L9	OUTPUT LUN
320 REM n$      neutral tokens
330 REM	o1=1	with lines
340 REM	o2=1	has print state
350 REM	r0,r1..	scratch registers
360 REM	t$	tab char
370 REM	t7$	keyword valid chars	(this and t8$ not implemented)
380 REM	t8$	keyword terminator characters
390 REM	t9$	tab+space
400 REM Initialize lots of good stuff the strings below are easily modified
410 READ F$,B$,N$,I$,I1$,I2$
420 DATA " LOOP IF IFB DO SELECT "," NEXT FI OD ESAC "
422 DATA " BREAK ELSE ELSEIF ELSEIFB CASE CASEB DEFAULT "
430 DATA "|...........","|","|           "
440 READ O1,O2,P$,L,L1,L9
450 DATA 1,1,"",0,0
451 DATA 2	
455 RETURN
460 I3$=I2$ \ IF O1=0 THEN I3$='            '
470 I3$=SEG$(I3$,1,4) \ I$=SEG$(I$,1,4) \ IF O1=0 THEN I$=""
480 T$=CHR$(9) \ T9$=T$+' '
490 RETURN
500 REM GET TOKEN A1$ INPUT, A1=1,2,3,4	 F,B,N,-
510 L$=''
520 R0=POS(A1$,' ',1) \ R1=POS(A1$,T$,1)
530 IF R0=0 THEN R0=255
540 IF R1=0 THEN R1=255
550 R2=R0 \ IF R0>R1 THEN R2=R1
560 IF R2=255 THEN A1$=A1$+' ' \ R2=LEN(A1$)
570 R$=SEG$(A1$,1,R2-1)+' '
580 R9=LEN(TRM$(R$))
590 IF SEG$(R$,R9,255)=':' THEN L$=L$+R$ \ GOSUB 680 \ GO TO 520
600 R1$=SEG$(A1$,1,R2)
610 R0=POS(F$,' '+R1$,1) \ IF R0<>0 THEN A1=1 \ GO TO 650
620 R0=POS(B$,' '+R1$,1) \ IF R0<>0 THEN A1=2 \ GO TO 650
630 R0=POS(N$,' '+R1$,1) \ IF R0<>0 THEN A1=3 \ GO TO 650
640 A1=4
650 L$=L$+'              ' \ R7=8 \ IF LEN(TRM$(L$))>8 THEN R7=LEN(TRM$(L$))+1
660 L$=SEG$(L$,1,R7)
670 RETURN
680 A$=SEG$(A1$,R9+1,255) \ GOSUB 690 \ RETURN
690 REM   O1=1
700 REM   LINPUT A$
710 REM   GOSUB 5040
720 REM   STOP
730 REM A$ IS INPUT, A1$ OUTPUT , ".PRINT ;" P$ STRIP OF THE .PRINT, HAS THE ADDRESS
740 IF O1=0 GO TO 810
750 R4=POS(A$,'.PRINT',1)
760 IF R4=0 GO TO 810
770 R5=POS(A$,';',R4)
780 P$=SEG$(A$,1,R4-4)+T$
790 A1$=SEG$(A$,R5+1,255)
800 GO TO 820
810 A1$=A$
820 IF POS(T9$,SEG$(A1$,1,1),1)=0 GO TO 840
830 A1$=SEG$(A1$,2,255) \ IF A1$<>'' GO TO 820
840 RETURN
850 REM indent with or without lines
860 REM a1$,a1,p$,l$ input l2$ is output
870 L2$=L$ \ REM label here
880 FOR R0=1 TO L
890 IF R0<>L THEN 920
900 IF A1=2 GO TO 930
910 IF A1=3 GO TO 930
920 L2$=L2$+I3$
930 NEXT R0
935 IF SEG$(A1$,1,1)=';' THEN A1$=T$+T$+T$+T$+A1$
940 ON A1 GO TO 950,980,1010,1020
950 L=L+1
960 L2$=L2$+A1$
970 RETURN
980 L2$=L2$+I$+A1$
990 L=L-1
1000 RETURN
1010 REM DROP THRU
1020 L2$=L2$+A1$
1030 RETURN
2000 CLOSE  \ A=SYS(4)
