<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic For loop in New Window in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215954#M43133</link>
    <description>&lt;P&gt;Hi! I am a very beginner JMP user, and am having trouble with getting my for loop to work.&amp;nbsp; 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!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open("Example1.jmp");
number = ncols(dt);


FactorType = {"Continuous", "Categorical"}; 
New Window("Data Entry", &amp;lt;&amp;lt; Modal, &amp;lt;&amp;lt; return results,
Text Box("Type of Factor");, 
type= V list Box(),
);

For(i= 1, i &amp;lt;= number, i++,
type &amp;lt;&amp;lt; Append(Radio Box(FactorType, Max Selected(1)));
);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 02 Jul 2019 17:54:22 GMT</pubDate>
    <dc:creator>dg1</dc:creator>
    <dc:date>2019-07-02T17:54:22Z</dc:date>
    <item>
      <title>For loop in New Window</title>
      <link>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215954#M43133</link>
      <description>&lt;P&gt;Hi! I am a very beginner JMP user, and am having trouble with getting my for loop to work.&amp;nbsp; 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!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open("Example1.jmp");
number = ncols(dt);


FactorType = {"Continuous", "Categorical"}; 
New Window("Data Entry", &amp;lt;&amp;lt; Modal, &amp;lt;&amp;lt; return results,
Text Box("Type of Factor");, 
type= V list Box(),
);

For(i= 1, i &amp;lt;= number, i++,
type &amp;lt;&amp;lt; Append(Radio Box(FactorType, Max Selected(1)));
);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jul 2019 17:54:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215954#M43133</guid>
      <dc:creator>dg1</dc:creator>
      <dc:date>2019-07-02T17:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: For loop in New Window</title>
      <link>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215972#M43136</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/15243"&gt;@dg1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;You're doing everything correctly! But, your use of &amp;lt;&amp;lt;Modal is inhibiting your script from functioning correctly. With a modal window, the remaining script is not executed until the OK button is clicked. If you remove &amp;lt;&amp;lt;modal your script will operate just fine, or alternatively, you can move the For() into the window statement.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open("Example1.jmp");
number = N Cols( dt );


FactorType = {"Continuous", "Categorical"};
New Window( "Data Entry",
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;return results,
	Text Box( "Type of Factor" ),
	type = V List Box(), 

	For( i = 1, i &amp;lt;= number, i++,
		type &amp;lt;&amp;lt; Append( Radio Box( FactorType, Max Selected( 1 ) ) )
	);

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2026"&gt;@jules&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 18:10:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215972#M43136</guid>
      <dc:creator>jules</dc:creator>
      <dc:date>2019-07-02T18:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: For loop in New Window</title>
      <link>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215974#M43137</link>
      <description>Thank 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?</description>
      <pubDate>Tue, 02 Jul 2019 18:21:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215974#M43137</guid>
      <dc:creator>dg1</dc:creator>
      <dc:date>2019-07-02T18:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: For loop in New Window</title>
      <link>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215976#M43138</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/15243"&gt;@dg1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;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:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open("Example1.jmp");
number = N Cols( dt );


FactorType = {"Continuous", "Categorical"};
New Window( "Data Entry",
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;return results,
	type = V List Box(), 

	For( i = 1, i &amp;lt;= number, i++,
		type &amp;lt;&amp;lt; Append( Text Box( "Type of Factor" ) );
		type &amp;lt;&amp;lt; Append( Radio Box( FactorType, Max Selected( 1 ) ) );
	);

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screen Shot 2019-07-02 at 2.26.27 PM.png" style="width: 202px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/18148i8FA3BA65BF696C35/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2019-07-02 at 2.26.27 PM.png" alt="Screen Shot 2019-07-02 at 2.26.27 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 18:27:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/215976#M43138</guid>
      <dc:creator>jules</dc:creator>
      <dc:date>2019-07-02T18:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: For loop in New Window</title>
      <link>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/216022#M43143</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/15243"&gt;@dg1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
number = N Cols( dt );
rbList = {};
rbResult = {};


FactorType = {"Continuous", "Categorical"};
win = New Window( "Data Entry",
	&amp;lt;&amp;lt;Modal,
	type = V List Box(), 
	
	Button Box( "OK",
		For( i = 1, i &amp;lt;= number, i++,
			rbResult[i] = rbList[i] &amp;lt;&amp;lt; Get Selected
		);

		win &amp;lt;&amp;lt; close window;
	), 
	
	
	For( i = 1, i &amp;lt;= number, i++,
		type &amp;lt;&amp;lt; Append( Text Box( "Type of Factor" ) );
		type &amp;lt;&amp;lt; Append( rbList[i] = Radio Box( FactorType ) );
	);

	
);

Print( rbResult );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you haven't yet, I highly suggest you read the JMP Scripting Guide, Help &amp;gt; Books &amp;gt; 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&amp;nbsp;&lt;A href="https://www.amazon.com/JSL-Companion-Applications-Scripting-Language/dp/1629609749/" target="_self" rel="nofollow noopener noreferrer"&gt;JSL Companion: Applications of the JMP Scripting Language.&amp;nbsp;&lt;/A&gt;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).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps you along your way! Enjoy!&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2026"&gt;@jules&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 18:56:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/216022#M43143</guid>
      <dc:creator>jules</dc:creator>
      <dc:date>2019-07-02T18:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: For loop in New Window</title>
      <link>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/216154#M43173</link>
      <description>&lt;P&gt;Is putting a for-loop in a new window function call really legitimate?&amp;nbsp; My view is that you shouldn't stick JSL in places where display boxes are expected, even if the code runs.&amp;nbsp; For a modal window, the JSL can be placed in the OnOpen event handler.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 17:37:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/216154#M43173</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2019-07-03T17:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: For loop in New Window</title>
      <link>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/216157#M43175</link>
      <description>That's a fair question, &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4536"&gt;@David_Burnham&lt;/a&gt;! 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.</description>
      <pubDate>Wed, 03 Jul 2019 18:25:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-loop-in-New-Window/m-p/216157#M43175</guid>
      <dc:creator>jules</dc:creator>
      <dc:date>2019-07-03T18:25:15Z</dc:date>
    </item>
  </channel>
</rss>

