For loop in New WindowHi! I am a very beginner JMP user, and am having trouble with getting my for loop to work. I am trying to ask the user what type of factor each of their factors are. The number of times the question is asked depends on the number of coloumns in the jmp file. I was attempting to use a radio box, but am having trouble with the appending. Below is little snapshot of what I have done. Thanks!
Names Default to Here(1);
dt = Open("Example1.jmp");
number = ncols(dt);
FactorType = {"Continuous", "Categorical"};
New Window("Data Entry", << Modal, << return results,
Text Box("Type of Factor");,
type= V list Box(),
);
For(i= 1, i <= number, i++,
type << Append(Radio Box(FactorType, Max Selected(1)));
);
Re: For loop in New WindowThat's a fair question, @David_Burnham! I think perhaps it depends? I use IfBox() quite a bit, though that's particularly designed for the conditional display of display boxes. I can't speak to the 'legitimacy' of jsl in these situations, but whatever the case OnOpen is a great suggestion.Re: For loop in New WindowIs putting a for-loop in a new window function call really legitimate? My view is that you shouldn't stick JSL in places where display boxes are expected, even if the code runs. For a modal window, the JSL can be placed in the OnOpen event handler.
Re: For loop in New WindowHi again @dg1,
Just to follow up, I looked a little more closely at your code and there were a few places where I think you'll hit a snag. The biggest is unloading the results. Each of your RadioBox() objects should have a handle so you can reference them later to grab the data. Below is one way to do that, that assigns the reference to a list, and then later steps through that list of references, sends the message to get the selected item, and stores the result to another list. This all happens when the OK button is clicked.
Names Default To Here( 1 );
dt = Current Data Table();
number = N Cols( dt );
rbList = {};
rbResult = {};
FactorType = {"Continuous", "Categorical"};
win = New Window( "Data Entry",
<<MODAL></MODAL>
If you haven't yet, I highly suggest you read the JMP Scripting Guide, Help > Books > Scripting Guide. It will be invaluable as you learn the language and the operations necessary to have a script work as you want. Also, I really enjoyed the book JSL Companion: Applications of the JMP Scripting Language. I would start with the Scripting Guide because it is included free in JMP, but the JSL Companion does provide a structured introduction to using JSL through a series of practical applications (and all the code is included).
Hope this helps you along your way! Enjoy!
@julian
Re: For loop in New WindowHi @dg1,
It appears to be showing up for me at the top of the window, but just the once as you have it programmed. If you want one textbox for each column selection, you could do another append in each iteration of your for() loop:
Names Default To Here( 1 );
dt = Open("Example1.jmp");
number = N Cols( dt );
FactorType = {"Continuous", "Categorical"};
New Window( "Data Entry",
<<MODAL></MODAL>

Re: For loop in New WindowThank you! Do you also know how to make sure the text box that says Type of Factor also shows up along with the Radio boxes?Re: For loop in New WindowHi @dg1,
You're doing everything correctly! But, your use of <
Names Default To Here( 1 );
dt = Open("Example1.jmp");
number = N Cols( dt );
FactorType = {"Continuous", "Categorical"};
New Window( "Data Entry",
<<MODAL></MODAL>
@julian