DECLARE FUNCTION RemoveColor$ (b$)
DEFINT A-Z
CONST MAXDATA = 42 '*what's the max # of the data file we're dealing with.
CONST SEEKSIZE = 8 '*What's the space to allow for offsets - 8-digit number.

DIM SHARED AnError

CLS

OPEN "LUNATIX3.DAT" FOR OUTPUT SHARED AS #2
'*** Create an empty header record!

FOR x = 0 TO MAXDATA
    AnError = 0
    ON ERROR GOTO NOPEN
    OPEN "DATA\ROOM" + LTRIM$(STR$(x)) + ".DAT" FOR INPUT SHARED AS #1
    ON ERROR GOTO 0
    IF AnError > 0 THEN GOTO LOOPER

   
    PRINT #2, ""
    PRINT #2, "FILE IS" + STR$(x) + "."

    WHILE NOT EOF(1)
        LINE INPUT #1, a$
        IF x <> 41 THEN
            IF LEN(LTRIM$(RTRIM$(a$))) > 0 THEN
                'b$ = Encode$(AntiEscape$(LTRIM$(a$)))
                b$ = LTRIM$(RTRIM$(a$))
                IF LEFT$(b$, 1) <> CHR$(27) AND LEFT$(b$, 1) <> "@" AND LEFT$(b$, 1) <> "#" AND LEFT$(b$, 1) <> "$" AND LEFT$(b$, 1) <> "/" AND LEFT$(b$, 1) <> ":" AND INSTR(UCASE$(b$), " X ") = 0 THEN
                    PRINT #2, RemoveColor$(b$) + " ";
                END IF
                IF LEFT$(b$, 1) = ":" THEN PRINT #2, ""
            END IF
        ELSE
            'IF LEN(LTRIM$(RTRIM$(a$))) = 0 THEN a$ = "   "
            'b$ = Encode$(a$)
            'PRINT #2, b$
        END IF
    WEND
LOOPER:
CLOSE #1
NEXT x

CLOSE #2

END

NOPEN: AnError = 1: RESUME NEXT

FUNCTION RemoveColor$ (b$)

FOR x = 1 TO LEN(b$)
    IF MID$(b$, x, 1) = "`" THEN
        MID$(b$, x, 1) = CHR$(1)
        IF x < LEN(b$) THEN MID$(b$, x + 1, 1) = CHR$(1)
    END IF
NEXT x
bs0$ = ""
FOR x = 1 TO LEN(b$)
    IF MID$(b$, x, 1) <> CHR$(1) THEN bs0$ = bs0$ + MID$(b$, x, 1)
NEXT x
RemoveColor$ = bs0$: bs0$ = ""

END FUNCTION

