I'm trying to generate a table box with a number of row which will be variable. I want each row to have button which will do some function to a corresponding variable in a list.
Current issue: The scripts in the for loop aren't interpreting eval expr as I expect. The resulting script attached to each checkbox should print that button 1, 2, or 3 was pressed. Instead it always says 4. End goal is to do an operation on UserText[i] when the checkbox is clicked.
Can anyone help explain what I am doing wrong? Thank you!
Bonus question: I'm using check boxes because they are smaller than buttons boxes and button boxes don't seem to be resizable. Ideally they would just be little clickable icons. Is there a friendly way to make a small clickable "x" instead of a full button?
JMP version: 16
Names Default To Here( 1 );
UserText = {"default 1", "default 2", "default 3"};
win2 = New Window( "Select files",
tb = Table Box(
Col Box( "Text", {} ),
Col Box( "Button", {} ),
),
tb << set row borders(1);
);
//for loop to add a number of rows with a small button next to each one
For( i = 1, i <= N Items( UserText ), i++,
tb << add row(
{Text Box( UserText[i], <<set width( 150 ) ),
Check Box( "",
Eval( Eval Expr( Print( "you pressed button " || Char( Expr( i ) ) ) ) )
)}
)
);
//this was my first thought, but this creates a script that contains "i" rather than the value of i
/*
For( i = 1, i <= 5, i++,
tb << add row(
{Text Box( UserText[i], <<set width( 300 ) ),
Check Box( "",
Print( "you pressed button " || Char( i ) )
)}
)
);
*/