Main      Site Guide    
Message Forum
Answer to Binary Prayers!
Posted By: Kaz!, on host 209.197.151.86
Date: Friday, February 4, 2000, at 21:19:13
In Reply To: Help!!! posted by ShadowClerk on Friday, February 4, 2000, at 16:07:44:

> I need a binary code converter (something that will convert text into binary code) for undisclosed purposes. (mostly showing off). If you have one or know of one, could you please reply?
>
> Shadow"10100101011"Clerk

I have spent the last 20 minutes developing a simple text to binary conversion program for QBASIC. I'll e-mail it to you. However, in case it doesn't work, here's the code for the program (copy it into a QBASIC file or text file with a .bas extension and run it from qbasic in order to get it to work.)
-Ka"1001011 1100001 111010 100001"z!

_________________________________________
CLS
DIM Numbers(1 TO 256) AS INTEGER
DIM BinNum AS LONG

PRINT "TEXT TO BINARY CONVERSION PROGRAM"
PRINT "This program has been created by Kaz! to turn text into binary code."
PRINT "It works by converting the text first into ASCII (American Standard"
PRINT "Code for Information Interchange) Code, which is how text is stored"
PRINT "as numbers inside of your computer. The ASCII Code numbers are then"
PRINT "converted into binary numbers using a quick and dirty (if inefficient)"
PRINT "routine. This program will work for text strings shorter than 255"
PRINT "characters; to do anything longer, you should run this program several"
PRINT "times."
PRINT
PRINT "Type text that is to be converted to binary"
LINE INPUT Text$

CLS
PRINT "TEXT TO BINARY CONVERSION PROGRAM"
PRINT
PRINT "First, the text will be converted into ascii codes:"

FOR Hopabout = 1 TO LEN(Text$)
Numbers(Hopabout) = ASC(MID$(Text$, Hopabout, 1))
PRINT Numbers(Hopabout);
NEXT Hopabout

PRINT
PRINT
PRINT "Press any key to continue..."
DO: LOOP UNTIL INKEY$ ""
CLS
PRINT "TEXT TO BINARY CONVERSION PROGRAM"
PRINT

PRINT "These codes will now be converted into binary:"
FOR Hopabout = 1 TO LEN(Text$)
BinNum = 0
IF Numbers(Hopabout) >= 128 THEN
BinNum = BinNum + 10000000
Numbers(Hopabout) = Numbers(Hopabout) - 128
END IF
IF Numbers(Hopabout) >= 64 THEN
BinNum = BinNum + 1000000
Numbers(Hopabout) = Numbers(Hopabout) - 64
END IF
IF Numbers(Hopabout) >= 32 THEN
BinNum = BinNum + 100000
Numbers(Hopabout) = Numbers(Hopabout) - 32
END IF
IF Numbers(Hopabout) >= 16 THEN
BinNum = BinNum + 10000
Numbers(Hopabout) = Numbers(Hopabout) - 16
END IF
IF Numbers(Hopabout) >= 8 THEN
BinNum = BinNum + 1000
Numbers(Hopabout) = Numbers(Hopabout) - 8
END IF
IF Numbers(Hopabout) >= 4 THEN
BinNum = BinNum + 100
Numbers(Hopabout) = Numbers(Hopabout) - 4
END IF
IF Numbers(Hopabout) >= 2 THEN
BinNum = BinNum + 10
Numbers(Hopabout) = Numbers(Hopabout) - 2
END IF
IF Numbers(Hopabout) >= 1 THEN
BinNum = BinNum + 1
Numbers(Hopabout) = Numbers(Hopabout) - 1
END IF
PRINT BinNum;
NEXT Hopabout

PRINT
PRINT
PRINT "Convert another text string (y/n)?"

DO
Hi$ = INKEY$
IF UCASE$(Hi$) = "Y" THEN RUN
LOOP UNTIL Hi$ ""

Replies To This Message