Hi Community,
I can use "for each item in list" to set blocks, as photos below.
But if I want to make only "all item in list", as my example below :
I want the background color of "all " items in list are grey, then change the Textbox color to yellow.
How can I set the blocks ?
Thanks for any help!
If I understand right your question is : if all items in list have grey background you want to set yellow the textbox ?
If you have only 5 items you can use an if control and 5 Boolean and as condition.
If background 1 is grey and background 2 is grey and background 3 is grey....... Then set yellow.
If you want to use the for each block you have to use a variable too. When for each starts if background is grey set variable as variable+1 , at the end of the for each if the variable= length of the list then set yellow . Variable starts from zero
Beware of using a color block for your grey test.
How are your Labels getting initialized?
Using the same block, or something that looks like grey?
Many Thanks for your detail reply !
In fact, there are over 30 items in the list, and every single items will change their color when something changed. So i want to having a result is : When All the items's background color are grey, the Textbox turns yellow.
@ewpatton 's solution works, even if you have a very long list, only if you add all Label in the List.
Thank You for your answer It works with your block's setting.
But inf fact, I don't know the meaning of the block "reduce list"
It's a bit of a term of art from the computer programming world, but the idea is that you are reducing a list of values down to a single value by combining some initial value X (sometimes called the base case) and applying a function f(X, Y) for each item Y in the list, updating X with the returned value of f.
So essentially the code I wrote starts with the value true, and then iterates over all of the labels in the list checking their background colors. On each step, it computes the logical and. If everything matches, then the value will remain true, but if at some point there isn't a match, the value will switch to false and remain that way (and only returns true if all inputs are true).