[Solved] Reducing the number of blocks needed for multiple switches

Hi there, I’m able to use the any component block to save the data to my Realtime DB. My dilema, as you can see from my blocks, I have 75 switches in the screen alone. Right now I have individual blocks to post the swithc value when the screen oopen. How can I use the any component block to eliminate 76 duplicate blocks and crete just one? I’ve tried several time to do it but I do not get any results. Thanks.

1 Like

@bobbyj12 moving this out to its own topic so that it get as little more attention from the community.

Did you ask something like this recently? I feel like I build this exact example for a user back in January?

@domhnallohanlon do you have a block or two you could share please?

Hey @bobbyj12, check this out. I think this may be what you are looking to do.

Check this sample app, in the navigator drawer choose screen “All the Switches”

I just reread this @bobbyj12

I’ll get back on this. I can solve this, for now, think about the use of any component, find component in list of, and having that index be the index for that switches value in a stored variable with 1 position for each switch.

Thanks @jared. I will attempt it. That would really reduce the number of repetitive blocks.

See it now

https://x.thunkable.com/copy/48f16125f5c64f2b94adb5514cffebe5
my example only has 6ish switches, but you could just continue to add switches with only 1 change to the block setup.
I think this is what you want.

If this works for you, please post back! Happy Thunking!

2 Likes

Hey @bobbyj12, I wonder if any of those solutions worked for you??

@jared That worked great. Thanks!!!

2 Likes

This is going to reduce the size of my app considerably. Thanks

1 Like