DECLARE FUNCTION bunny$ (a$)
OPEN "ttt.txt" FOR BINARY AS #1
OPEN "ttt" FOR OUTPUT AS #2
DO
a$ = INPUT$(1, 1)
IF ASC(a$) > 32 THEN PRINT #2, a$,
IF ASC(a$) <= 32 THEN PRINT #2, "X",
b$ = bunny$(a$)
PRINT #2, b$

LOOP UNTIL EOF(1)
CLOSE #2
CLOSE #1

FUNCTION bunny$ (a$)
a = ASC(a$)
d$ = "00000000"
IF a >= 128 THEN MID$(d$, 1, 1) = "1": a = a - 128
IF a >= 64 THEN MID$(d$, 2, 1) = "1": a = a - 64
IF a >= 32 THEN MID$(d$, 3, 1) = "1": a = a - 32
IF a >= 16 THEN MID$(d$, 4, 1) = "1": a = a - 16
IF a >= 8 THEN MID$(d$, 5, 1) = "1": a = a - 8
IF a >= 4 THEN MID$(d$, 6, 1) = "1": a = a - 4
IF a >= 2 THEN MID$(d$, 7, 1) = "1": a = a - 2
IF a >= 1 THEN MID$(d$, 8, 1) = "1": a = a - 1

bunny$ = d$
END FUNCTION

