Scripting a text to binary digits converter

-=>JB<=- sundown at pacifier.com
Mon Jan 2 15:36:48 EST 2012


When I did a quick read of binaryEncode() I was thinking
it said you could enter the number of chars you want to
convert which would eliminate the need for a repeat
structure but I did not try it and could be wrong.

-=>JB=-


On Jan 2, 2012, at 12:23 PM, Bryan McCormick wrote:

> JB, Guglielmo
> 
> This appears to work for my purposes and is pretty speedy. See anything that might break?
> 
> ---------------------------------------
> 
> function convertTextToBinary varText
>   repeat with n = 1 to the number of chars of varText
>      put chartonum(char n of varText) into theNum
>      if theNum >=64 and theNum <= 127 then
>         put "0"&baseConvert(theNum,10,2) after tConverted
>      else if theNum <="64" then
>         put "00"&baseConvert(theNum,10,2) after tConverted
>      else
>         put baseConvert(theNum,10,2) after tConverted
>      end if
>   end repeat
>   return tConverted
> end convertTextToBinary
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 





More information about the use-livecode mailing list