<?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 Re: How to loop using a function in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-loop-using-a-function/m-p/75208#M35903</link>
    <description>&lt;P&gt;First off, if you are going to pursue JSL coding, you need to thourthly read the Scripting Guide&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Help==&amp;gt;Books==&amp;gt;Scripting Guide&lt;/P&gt;
&lt;P&gt;Below is a reworking of your script to illustrate how to loop using a function and how to keep all of the output in the same output journal.&amp;nbsp; I know it is not exactly what you need, but it should give you a good start on how to do what you want&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

doGraphPlot = Function( 
		
	{dt, Xaxis, Yaxis, Grby, chnl}, 
	
	Eval(
		Substitute(
				Expr(
					gb = dt &amp;lt;&amp;lt; Graph Builder(
						invisible,
						where( dt:Channel == __chnl__ ),
						size( 600, 400 ),
						show control panel( 0 ),
						variables(
							Y( Eval( Yaxis ) ),
							X( Eval( Xaxis ) ),
							Group X( Eval( Xgrby ) ),
							Overlay( :RowCol )
						),
						elements( smoother( X, Y, legend( 19 ), lambda( 0.0001 ) ) )
					)
				),
			Expr( __chnl__ ), chnl
		)
	);
	
	Report( gb )[Outline Box( 1 )] &amp;lt;&amp;lt; set title( "Channel = " || Char( chnl ) );
	
);

jjrn = New Window( "Data Plot - Output_1 vs Input", &amp;lt;&amp;lt;Journal );
	
dtsum = dt &amp;lt;&amp;lt; Summary( Group( :Channel ), invisible ); //

Yaxis = Expr(
	Column( dt, "Output_1" )
);
Xaxis = Expr( Column( dt, "Input" ) );
Xgrby = Expr(
	Column( dt, "wafer_number" )
);

For( i = 1, i &amp;lt;= N Row( dtsum ), i++,
	chnl = dtsum:Channel[i];

	doGraphPlot( dt, Yaxis, Xaxis, Xgrby, chnl );
	
	jjrn &amp;lt;&amp;lt; append( Report( gb ) );
	gb &amp;lt;&amp;lt; close window;

);

Yaxis = Expr(
	Column( dt, "Output_3" )
);
Xaxis = Expr( Column( dt, "Input" ) );
Xgrby = Expr(
	Column( dt, "wafer_number" )
);

For( i = 1, i &amp;lt;= N Row( dtsum ), i++,
	chnl = dtsum:Channel[i];

	doGraphPlot( dt, Yaxis, Xaxis, Xgrby, chnl );
	
	jjrn &amp;lt;&amp;lt; append( Report( gb ) );
	gb &amp;lt;&amp;lt; close window;

);

Close( dtsum, nosave );
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 22 Sep 2018 16:56:59 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-09-22T16:56:59Z</dc:date>
    <item>
      <title>How to loop using a function</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-using-a-function/m-p/74841#M35866</link>
      <description>&lt;P&gt;The difference between Function() and Expr(). After &lt;A href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4553" target="_blank"&gt;&lt;FONT color="#0066cc"&gt;msharp&lt;/FONT&gt;&lt;/A&gt;&amp;nbsp;answered my question yesterday, i realized that i have been doing this all wrong. Currently every output whether it is a Graph Plot or Distribution had its own individual Expr() with 3 different iterations inside of it. In a nutshell, that is ~ 20 Expr() scripts. The ability to use a Function would cut that down to one graph plot script and one distribution script. What i am having difficulty doing is now looping through the function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the sample data table, a sample of just one of the expressions i use to graph plot and the start of a function script. I would apprecaite any help in solving this problem. I can use the solution to this problem and apply to many others. You can run the original script to understand what i am trying to do..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S if you have the time i am trying to combine the 3 journals into a single journal. I am trying to back into a script that posted on this thread&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/Combine-multiple-journals-into-one-journal/td-p/6129" target="_blank"&gt;https://community.jmp.com/t5/Discussions/Combine-multiple-journals-into-one-journal/td-p/6129&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:37:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-using-a-function/m-p/74841#M35866</guid>
      <dc:creator>Yngeinstn</dc:creator>
      <dc:date>2018-09-21T12:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop using a function</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-using-a-function/m-p/75208#M35903</link>
      <description>&lt;P&gt;First off, if you are going to pursue JSL coding, you need to thourthly read the Scripting Guide&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Help==&amp;gt;Books==&amp;gt;Scripting Guide&lt;/P&gt;
&lt;P&gt;Below is a reworking of your script to illustrate how to loop using a function and how to keep all of the output in the same output journal.&amp;nbsp; I know it is not exactly what you need, but it should give you a good start on how to do what you want&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

doGraphPlot = Function( 
		
	{dt, Xaxis, Yaxis, Grby, chnl}, 
	
	Eval(
		Substitute(
				Expr(
					gb = dt &amp;lt;&amp;lt; Graph Builder(
						invisible,
						where( dt:Channel == __chnl__ ),
						size( 600, 400 ),
						show control panel( 0 ),
						variables(
							Y( Eval( Yaxis ) ),
							X( Eval( Xaxis ) ),
							Group X( Eval( Xgrby ) ),
							Overlay( :RowCol )
						),
						elements( smoother( X, Y, legend( 19 ), lambda( 0.0001 ) ) )
					)
				),
			Expr( __chnl__ ), chnl
		)
	);
	
	Report( gb )[Outline Box( 1 )] &amp;lt;&amp;lt; set title( "Channel = " || Char( chnl ) );
	
);

jjrn = New Window( "Data Plot - Output_1 vs Input", &amp;lt;&amp;lt;Journal );
	
dtsum = dt &amp;lt;&amp;lt; Summary( Group( :Channel ), invisible ); //

Yaxis = Expr(
	Column( dt, "Output_1" )
);
Xaxis = Expr( Column( dt, "Input" ) );
Xgrby = Expr(
	Column( dt, "wafer_number" )
);

For( i = 1, i &amp;lt;= N Row( dtsum ), i++,
	chnl = dtsum:Channel[i];

	doGraphPlot( dt, Yaxis, Xaxis, Xgrby, chnl );
	
	jjrn &amp;lt;&amp;lt; append( Report( gb ) );
	gb &amp;lt;&amp;lt; close window;

);

Yaxis = Expr(
	Column( dt, "Output_3" )
);
Xaxis = Expr( Column( dt, "Input" ) );
Xgrby = Expr(
	Column( dt, "wafer_number" )
);

For( i = 1, i &amp;lt;= N Row( dtsum ), i++,
	chnl = dtsum:Channel[i];

	doGraphPlot( dt, Yaxis, Xaxis, Xgrby, chnl );
	
	jjrn &amp;lt;&amp;lt; append( Report( gb ) );
	gb &amp;lt;&amp;lt; close window;

);

Close( dtsum, nosave );
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Sep 2018 16:56:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-using-a-function/m-p/75208#M35903</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-09-22T16:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop using a function</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-loop-using-a-function/m-p/75319#M35915</link>
      <description>&lt;P&gt;Thank you Mr. Nelson,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate the help you and the community provides. I must tell you that coding in general is very new and hard for me. You are talking to a person who got a 'C' in C++ and ran with it. For every hour that i spend coding, I spend 3 hours reading the Scripting Guide, using the Scripting Index and of course reading through the forums. Due to my ignorance with coding in general and then trying to translate that into JSL, I spend a significant amount of time on my own time learning. I am usual spending my time reading code that was posted here and try to back into with what i am trying to do.&amp;nbsp;I am signing up for the webinars to learn more and espically get a handle on JMP 14 when it rolls out in the very near future. I apologize if i am asking too many questions and seeking help more than any other individuals.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With that said, thanks again for your help.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Sep 2018 16:40:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-loop-using-a-function/m-p/75319#M35915</guid>
      <dc:creator>Yngeinstn</dc:creator>
      <dc:date>2018-09-23T16:40:41Z</dc:date>
    </item>
  </channel>
</rss>

