Binary String to Enable Objects

Alex Tweedly alex at tweedly.net
Sat Nov 19 09:57:23 EST 2005


Eric Chatonet wrote:

> Hello X,
>
> The best way (for me :-) should be to set the altIDs of the 32  
> controls in reference to the binary list (or use the IDs directly if  
> they match the right sequence):
> Then, for instance, if IDs (or altIDs) are 2001 to 2032:
>
> local tBinStr -- your binary string
> -----
> lock screen
> repeat with i = 1 to 32
>   set the enabled of control ID (i + 2000) to (item i of tBinStr = 1)
> end repeat
> unlock screen
>
That's neat !  I would never have thought of using the IDs - I've never 
set an ID to a specific value, but I'll probably remember to consider 
this idea now - thanks. 

I would have done something rather less robust, such as naming the 
controls something like Bit1, Bit2, ... Bit32 and used something like
     set the enabled of control tControlName to ...

btw I think the string is a text string representing a binary number, so 
it would actually be
     set the enabled of control ("Bit" & i) to (char i of tBinStr = "1")

(Or, if the controls needed to have meaningful names for other purposes, 
then I'd have used an array or customproperty to map numbers to control 
names).

> Hope this helps.
>
> Le 19 nov. 05 à 12:33, Camm29 a écrit :
>
>> I have a Binary String say "00001100101011011100101010101010"
>> I then wish to enable or disable upto 32 Objects depending on "0"  or 
>> "1" of the String.
>> Each bit being alloacated to a a different Object.
>> Is there an easy way !
>
>
> Best Regards from Paris,
>
> Eric Chatonet.



-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.2/170 - Release Date: 15/11/2005




More information about the use-livecode mailing list