Idris
1
I have a list of buttons.
I want to set whether or not they're enabled based on bits in a corresponding binary integer.
So I want to do something like the code below, but I can't find blocks with which to do it in AI2.
Any suggestions?
for (int i=0; i<10, i++)
{
if (bitRead(A , i) == 1)
{
button_list.enable[i] = true;
}
else
{
button_list.enable[i] = false;
}
}
Idris
3
A = 1110001010
Bit 0 of A = 0 so button#0 is disabled
Bit 3 of A = 1 so button#3 is enabled
TIMAI2
4
Probably this:
[EDIT - the for each item in list
is the incorrect block to use, see a few posts down for the correct blocks]
Depending on your Android version, you may need this:
earlier versions of android add an empty list item at index 1 when splitting characters with an empty string
Idris
5
The IDE won't accept the two instances of "binary" as and argument when it needs a list ... and I can see why.
And I can't get my head round the concept of "thing". (Even after repeatedly reading the documentation.)
TIMAI2
6
Explain what you mean - IDE ?
Show your blocks
TIMAI2
7
Sorry, my error, you need to use the for each number from block
1 Like
system
Closed
10
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.