Scripting a text to binary digits converter

Bryan McCormick bryan at deepfoo.com
Mon Jan 2 15:54:04 EST 2012


JB,

Well it gives some peculiar results because I clearly don't know much 
about the encoding process in terms of passing the right params.

I rewrote this to be more general. Give it a try if you like and let me 
know. It will handle carriage returns and such properly.

Seems speedy enough for me but again, I am sure it can be improved upon.

Thanks for your help, most generous of you.


----------------------

function convertTextToBinary varText
    repeat with n = 1 to the number of chars of varText
       put chartonum(char n of varText) into theNum
       put baseConvert(theNum,10,2) into tBaseConverted
       if length(tBaseConverted) <8 then
          repeat until length(tBaseConverted)= 8
             put "0" before tBaseConverted
          end repeat
       end if
       put tBaseConverted after tConverted
    end repeat
    return tConverted
end convertTextToBinary





More information about the use-livecode mailing list