> function convertTextToBinary varText
> --repeat with n = 1 to the number of chars of varText
> repeat for each char tChar in varText
> --put chartonum(char n of varText) into theNum
> put chartonum(tChar) into theNum
> put baseConvert(theNum,10,2) into tBaseConverted
> put char -8 to -1 of ("00000000" & tBaseConverted ) into tBaseConverted
> put tBaseConverted after tConverted
> end repeat
> return tConverted
> end convertTextToBinary
Another thing you could do which *might* speed things up is to use numberFormat
instead of parsing strings:
function convertTextToBinary varText
set the numberFormat to "00000000"
--repeat with n = 1 to the number of chars of varText
repeat for each char tChar in varText
--put chartonum(char n of varText) into theNum
put chartonum(tChar) into theNum
put (baseConvert(theNum,10,2)+0) into tBaseConverted -- the "+0" forces
it to use the number format
put tBaseConverted after tConverted
end repeat
return tConverted
end convertTextToBinary
You can also collapse a lot of the code (although it's less readable):
function convertTextToBinary varText
set the numberFormat to "00000000"
repeat for each char tChar in varText
put (baseConvert(chartonum(tChar),10,2)+0) after tConverted
end repeat
return tConverted
end convertTextToBinary
Stripping a few lines may also increase speed - don't know but just a thought...
Ken Ray
Sons of Thunder Software, Inc.
Email: [email protected]
Web Site: http://www.sonsothunder.com/
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode