10 ' CHARFLIP.BAS version 1.0 (C) 1985 Merlin R. Null
20 ' For modifying banner font source files.
30 ' This program may not be sold separately or as part of any
40 ' collection of programs or used as an inducement to buy any other
50 ' product or program without the written permission of the author:
60 ' Merlin R. Null, P.O. Box 9422, N. Hollywood, CA 91609, (818) 762-1429
70 DEFINT A-Z
80 DIM LIN$(100)
90 ON ERROR GOTO 1040
100 OPEN "I",#1,"CLS.DAT"
110 WHILE NOT EOF(1)
120   LINE INPUT #1, A$
130   CLS$=CLS$+CHR$(VAL(A$))
140 WEND
150 CLOSE #1
160 BL$=CHR$(7)
170 PRINT CLS$
180 PRINT"CHARFLIP version 1.0  (C) 1985 Merlin R. Null  9/14/85"
190 PRINT STRING$(54,45)
200 PRINT"	For modifying banner font source files"
210 PRINT STRING$(3,10)
220 PRINT"1. Rotate a character graphic file 180 degrees."
230 PRINT:PRINT
240 PRINT"2. Create a mirror image of the input file."
250 PRINT STRING$(3,10)
260 PRINT"<NOTE> The input file must be 100 lines or less in length."
270 PRINT:PRINT
280 PRINT"Option? ";
290 OPT$=INPUT$(1)
300 PRINT OPT$
310 IF ASC(OPT$)<49 OR ASC(OPT$)>50 THEN PRINT BL$:GOTO 170
320 PRINT:PRINT
330 INPUT"Input filename or <RETURN> to exit";FILENAME$
340 GOSUB 920	' Check the name
350 INFILE$=FILENAME$
360 PRINT:PRINT
370 INPUT"Output filename or <RETURN> to exit";FILENAME$
380 GOSUB 920	' Check the name
390 OUTFILE$=FILENAME$
400 IF OUTFILE$=INFILE$ THEN PRINT BL$; ELSE 430
410   PRINT"Output filename must be different from Input filename."
420   GOTO 360
430 IF OUTFILE$=""THEN 670
440 OPEN "I",#2,OUTFILE$
450 CLOSE
460 PRINT:PRINT
470 PRINT OUTFILE$;" already exists.  Do you wish to overwrite it";
480 INPUT ANS$
490 IF LEFT$(ANS$,1)<>"Y" AND LEFT$(ANS$,1)<>"y" THEN 670
500 PRINT
510 OPEN "I",#1,INFILE$
520 PRINT"Reading ";INFILE$
530 WHILE NOT DONE
540   ROW=ROW+1
550   LINE INPUT #1,LIN$(ROW)
560   IF LEN(LIN$(ROW))>MAXLEN THEN MAXLEN=LEN(LIN$(ROW))
570   IF ROW=100 OR EOF(1) THEN DONE=-1
580 WEND
590 OPT=VAL(OPT$)
600 PRINT
610 PRINT"Writing ";OUTFILE$
620 OPEN "O",#2,OUTFILE$
630 ON OPT GOSUB 700,860
640 CLOSE
650 PRINT
660 PRINT"Done."
670 PRINT:PRINT
680 END
690		' Write 180 degree rotated file
700 FOR I=1 TO ROW
710   LIN$(I)=LIN$(I)+STRING$(MAXLEN-LEN(LIN$(I)),32)
720 NEXT I
730 FOR I=ROW TO 1 STEP -1
740   FOR K=1 TO LEN(LIN$(I))
750     IF MID$(LIN$(I),K,1)<> " " THEN 770
760   NEXT K
770   FOR J=LEN(LIN$(I)) TO 1 STEP -1
780     TEMP$=TEMP$+MID$(LIN$(I),J,1)
790   NEXT J
800   TEMP$=LEFT$(TEMP$,LEN(TEMP$)-(K-1))
810   PRINT #2,TEMP$
820   TEMP$=""
830 NEXT I
840 RETURN
850		' Write mirror image file
860 FOR I=ROW TO 1 STEP -1
870 TEMP$=LIN$(I)
880   PRINT #2,TEMP$
890 NEXT I
900 RETURN
910		' Case and ";" conversion
920 IF FILENAME$="" THEN 670
930 FOR I=1 TO LEN(FILENAME$)
940   BYTE=ASC(MID$(FILENAME$,I,1))
950   IF BYTE>96 AND BYTE<123 THEN MID$(FILENAME$,I,1)=CHR$(BYTE-32)
960   IF BYTE=59 THEN MID$(FILENAME$,I,1)=":"
970 NEXT I
980 NAMELEN=LEN(FILENAME$)-INSTR(FILENAME$,":")
990 IF INSTR(FILENAME$,".")=0 THEN 1010
1000 EXTLEN=LEN(FILENAME$)-(INSTR(FILENAME$,".")-1)
1010 IF NAMELEN-EXTLEN>8 THEN ERROR 200
1020 EXTLEN=0
1030 RETURN
1040 IF ERR=53 AND ERL=440 THEN CLOSE ELSE 1060
1050   RESUME 500
1060 IF ERR=53 AND ERL=510 THEN PRINT CLS$ ELSE 1100
1070   PRINT STRING$(3,10)
1080   PRINT INFILE$;" not found"
1090   RESUME 670
1100 IF ERR=200 THEN PRINT CLS$ ELSE 1140
1110   PRINT STRING$(3,10)
1120   PRINT"BAD FILE NAME";BL$
1130   RESUME 670
1140 IF ERR=53 AND ERL=100 THEN CLOSE #1 ELSE 1380
1150   PRINT STRING$(18,10)
1160   PRINT BL$;"CLS.DAT, the clear screen data file, not found."
1170   PRINT"Please enter your clear screen sequence"
1180   PRINT"one byte at a time in Decimal numbers.  End your"
1190   PRINT"entries with a <RETURN> to generate CLS.DAT"
1200   PRINT:PRINT
1210   FOR I=1 TO 9
1220     PRINT"Clear Screen character";I;
1230     LINE INPUT C$
1240     IF C$="" AND I>1 THEN 1330
1250     IF C$="" THEN 1220
1260     IF LEN(C$)>3 THEN 1220
1270     FOR J=1 TO LEN(C$)
1280       IF ASC(MID$(C$,J,1))<48 OR ASC(MID$(C$,J,1))>57 THEN PRINT BL$;

           "Whole decimal numbers only.":GOTO 1220
1290     NEXT J
1300     IF I>1 THEN CLR$=CLR$+CHR$(13)+CHR$(10)
1310     CLR$=CLR$+C$
1320   NEXT I
1330   PRINT"Writing CLS.DAT";
1340   OPEN "O",#1,"CLS.DAT"
1350   PRINT #1,CLR$
1360   CLOSE #1
1370   RESUME 100
1380 ON ERROR GOTO 0
