05-07-2003, 11:53 AM
This is my first post here...Hi everyone.
I recently wrote a sub (text2bin) that does what you ask. Here's a snipet of code that will operate as a stand alone program...My original code transfered a string to a bit-sequence. However, I've placed the print statements so that they meet your requirements. I used this code in an encryption program I wrote. See:
http://www.tcdn.teiher.gr/upload/downloa...fileid=678
Anyway...this does what you want.
CLS
pwa$ = "JOE"
DIM binaryarray(1 TO (8 * LEN(pwa$))) AS INTEGER
p = 1
FOR x = 1 TO LEN(pwa$)
p$ = MID$(pwa$, x, 1)
byte = ASC(p$)
PRINT p$; "=";
FOR y = 7 TO 0 STEP -1
power = 2 ^ y
binaryarray(p) = byte \ power
IF binaryarray(p) = 1 THEN byte = byte - power
PRINT binaryarray(p);
p = p + 1
NEXT y
PRINT
NEXT x
I recently wrote a sub (text2bin) that does what you ask. Here's a snipet of code that will operate as a stand alone program...My original code transfered a string to a bit-sequence. However, I've placed the print statements so that they meet your requirements. I used this code in an encryption program I wrote. See:
http://www.tcdn.teiher.gr/upload/downloa...fileid=678
Anyway...this does what you want.
CLS
pwa$ = "JOE"
DIM binaryarray(1 TO (8 * LEN(pwa$))) AS INTEGER
p = 1
FOR x = 1 TO LEN(pwa$)
p$ = MID$(pwa$, x, 1)
byte = ASC(p$)
PRINT p$; "=";
FOR y = 7 TO 0 STEP -1
power = 2 ^ y
binaryarray(p) = byte \ power
IF binaryarray(p) = 1 THEN byte = byte - power
PRINT binaryarray(p);
p = p + 1
NEXT y
NEXT x