Get random color from list BUT dont get the same color

I have a simple get random color from list but sometimes it gets the same color and its if the button is not working… So i need to tell the app to dont get the same color but any one of the others… please advice. Also I want max 10 colors so i dont want to do 0-255…

You can have two lists A and B, A initially having all the colours and B being empty.
When you pick a colour from A, remove that list item from A and add it to B.
In the same procedure, check if A is empty. If so, set the contents of B to A.

Effectively, you’re picking colours at random and then removing them from the sample space. (List B and the check are not required if you don’t want to retain/reuse your colours)


wow thanks! but how would you build this? could you please show me?

Something like this should do


And here’s how to use it

1 Like

Hello @andersenrichard86
Just in case if you want another similar example as @Vishwas already suggested , then here :point_down: is one by @Taifun

How to pick a random item from a list without picking duplicates?


AMAZING guys, but i dont have one item but 4 that needs to be changed to the same random color… how would i be able to do that?

Create a local variable and initialise it to the result from the PickRandomProcedure procedure.
Set each of the properties to that variable.

1 Like

You see im changing color to 4 seperate elements that makes a “theme” for the app. So i need users to be able to change to a random theme, but also i would need the app to save the current theme/color so that when the user closes and reopens the app, it gets the same random color that the user picked last… really appreciate your help, thanks

Okay thanks but there are several local variable blocks and i dont know how to place them to get the correct result that you are speaking of… Could you please show me what blocks go where to make this work?

This should work.

All the properties you wish to change must be set inside the SetTheme procedure.
The theme is saved using TinyDB in the device’s storage and is fetched when the screen is initialised. If no theme exists, a random colour is used as the theme.

And feel free to replace “” with the event you wish to change the theme from.

Hope this helps!


Awesome, it works! I wish I had your set of skills in this. But at least I’m learning as I go :stuck_out_tongue:
There is a final problem though, upon screen initialize I get this error…:

Swap the tag and value If Tag Not There blocks in Screen1.Initialize.
And rename the tag to something other than the name of the variable in the SetTheme procedure (“themeData” is a valid tag name, for example).

1 Like

Yay, thanks alot! So a last question, say when the app is installed and loaded for the first time i want the theme color to be cyan. How could I implement this? Lets call this a “default” theme… thanks

1 Like

Replace the value If Tag Not There block with the cyan colour block.
TinyDB is a storage service that stores data as tag/value pairs.

When your app is run for the first time, there is no “themeData” tag. So the value If Tag Not There fallback value is used.

1 Like

Thats crazy, I had an idea about doing that but never thought it would be that easy. Your support has been life saving. Everything is working smooth, Thanks for all your help.


Glad to help!


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.