[Solved] Help using any component blocks to set variables

I have 5 dynamic rows with 5 buttons in each.
each row is assigned 1 variable

so, the user picks 1 option (clicks 1/5 buttons) and i want that button choice assigned to the button for that row. currently my code for that looks like this.

i have shortened it to this

if you can see each row 60-64 is assigned to it’s own Dataformat variable. Is there a way to combine these into less blocks? or since i am dealing with variables, does each need it’s own set of control blocks?

in row 60 there would be 5 buttons. when any of the buttons is clicked i want storedbehaivor1 set to that buttons text.

i want to do that for rows 60/storedbehavior1, row 61/storedbehavior2 etc.

In the second screenshot, it looks like what you’re doing is taking the button ID (component), checking to see if it’s a button in a particular column and row, and if so, changing its property.

Is there a reason you’re checking to see if each button is part of a column and part of a row?

This looks like an inefficient way to check a button’s membership. Why not just create a list of button #s and then check that list once when a button is clicked to see if it’s a member? That way instead of having a bunch of loops (for j from 1 to 5), you just have a single list lookup.

sure! great point! column 10 is made up of several rows for formatting purposes. maybe i could use some guidance here. idk how else to make it looks the right way

The variable aspect is a little tricky. I’m not sure how the local database works – is that what you’re using with all those BX4_Dataformat variables? – but if you can specify a row/column pair or use a list and store the whole list, you can use index values to save things in a single block (as I suggested just above) instead of having separate variable values everywhere.

As a general rule of thumb, if you’re creating multiple variables that have to be numbered (Level 1 score, Level 2, score, Level 3, score, etc.), that’s a good indication that a list or table is a way better way of storing that information.

oh boy! a new challenge! figuring out how to do that would save me so many variables. it would just require remembering the correct index fora beahvior.

your example would be something like

Var Stored behaviors: index 1, behavior 1; index 2, beavhior 2 etc?

Screen Shot 2020-01-22 at 3.22.56 PM

take out the loop?

Possibly! Do you know why you’re checking to see if a button is part of a row or column? If there’s not a specific reason, I think you can replace the multiple loops with something better.

I had to play with this but it makes sense. I was able to reduce in a test app 16 to a single list saved in 1 variable. i will share the code and app here. it is a simple discrete trial teaching data collection tool used in an ABA therapy setting.

currently the app is set up to measure 5 things in a % format. it only takes 18 blocks total and 0 extra variables per measure now instead of wayy more.

I have also made use of the anycomponent blocks a lttle bit more!


1 Like