LSB MSB > 0000 0000 0000 0001I went home and converted a VB program to FoxPro that is suppose to convert to 8bit characters. The outputs of the two programs are identical. Here is the FoxPro program but I still don’t understand how that’s 8bit or how to make it more than 8bit. For some reason the first value in the array must be 256 and the last two 257 and 0
PRIVATE la_Values DIMENSION la_Values[4] la_Values[1] = 256 la_Values[2] = ASC('T') la_Values[3] = 257 la_Values[4] = 0 ? Eight_Bit(@la_values) FUNCTION Eight_Bit(pa_values) LOCAL lc_bits, ; lc_return, ; ln_cntr, ; ln_alen STORE SPACE(0) TO lc_bits, ; lc_return ln_alen = ALEN(pa_Values) - 1 FOR ln_cntr = 1 TO ln_alen + 1 lc_bits = PADL(Num2Bin(pa_values(ln_cntr)), 9, '0') + lc_bits ENDFOR FOR ln_cntr = (LEN(lc_bits) - 7) TO 1 STEP -8 lc_return = lc_return + CHR(Bin2Num(SUBSTR(lc_bits, ln_cntr, 8))) ENDFOR *-- Drop the first one it's always chr(0) lc_return = SUBSTR(lc_return, 2) RETURN (lc_return) FUNCTION Num2Bin(pn_num) LOCAL ln_num, ; lc_bin lc_bin = SPACE(0) ln_num = pn_num DO WHILE ln_num <> 0 lc_bin = TRANSFORM(MOD(ln_num, 2)) + lc_bin ln_num = INT(ln_num / 2) ENDDO RETURN (lc_bin) FUNCTION Bin2Num(pc_bin) LOCAL ln_cntr, ; ln_num ln_num = 0 FOR ln_cntr = 1 TO LEN(pc_bin) IF SUBSTR(pc_bin, ln_cntr, 1) = "1" ln_num = ln_num + 2 ^ (LEN(pc_bin) - ln_cntr) ENDIF ENDFOR RETURN (ln_num)