Background colour specific bit from integer


I have a few buttons that have to toggle bits in an integer.

By scripying and some google search I was able to make a script where I can toggle specific bits from an integer tag.

Now when the specific bit is TRUE i want the corresponding button to turn green.

When I go to the properties of the button I can change the background but the problem is that the tag is an integer. Is there a way to select a specific bit maybe through “indirect tag”? Or an expression?

So my question in short; What’s the best way to change a background colour of a button where the colour has to change according to a specific bit of an integer tag.

Thanks in advance!


Try something like this, in an Expression binding. Replace the property reference with a tag as appropriate:

if( //open conditional
	getBit({Root Container.Numeric Text Field.intValue}, 1), //get the value of the bit in position 1 (0-indexed)
	"255, 0, 0", //if that bit is 1 (shorthand for a True value), return a particular color (red, green, blue)
	"255, 255, 0" //if that bit is 0, return a 'fallback' color
1 Like

Rather than using individual bits and scripting, just move to an integer value for the color state and use the “style customizer” feature.

You could also create individual integer bit tags, but that’s a bit much too.

1 Like

PGriffith thank you this works perfectly!

Paullys50 the problem with using the integer value itself is that its not always only 1 bit that can be TRUE.

I have 16 Bits for selecting different options during a sequence.

So the integer value could be 1000 0001 -> Where two buttons have to light op green


1110 0001 -> Where 4 buttons have to light up green. This is why I can’t just link the integer value itself, but PGriffith’s option wors great!