Hi. I'm wondering if there's a convenient method for a button box to somehow know where it lies within a lineup box. My specifics:
JMP Pro 16.2.0
I have a script that creates a window with a LineUp box. In each cell, there's a button box that I want to perform a different action, based on which column the button appears in. For example:
Names Default to Here(1);
list = {"cat", "dog", "mouse", "kangaroo", "sloth"};
list2 = {"meow", "bark", "squeak", "hop", "zzz"};
lub = LineUpBox(NCol(2), Spacing(5));
For(i=1, i<=NItems(list), i++,
tb = TextBox(list[i]);
bb = ButtonBox(list2[i],
//Insert code for the button to somehow identify which button it is within lub.
Speak(list2[i])
);
lub << Append(tb);
lub << Append(bb);
);
New Window("Test", lub);
If I run the script as is, I get:
But when I click on any of the buttons, I get the error:
"Subscript Range in access or evaluation of 'list2[ /*###*/i]' , list2[/*###*/I]"
I understand this error because there's no way for the button box to recall the value of "i" when executed. My question: is there a method I could use that would allow the button box to "self-identify" where it lies in the line up box when pressed, and use that value as the list2 index in the button script?
I'm currently using JSL Quotes and the Substitute command to create the buttons. In that case I write the contents of the For loop as a JSL Quote and substitute in the value of i, then Eval(Parse()). This is clunky though, and I'm wondering if there's a better way, like a "bb << Get Location" or "bb << Count Siblings" command. These commands don't exist of course, but perhaps there's another technique?
Thanks!