<?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 do replace contents in the function with a placeholder? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/628331#M82664</link>
    <description>&lt;P&gt;Are you really trying to just make graph builder dynamic?&amp;nbsp; Something like this?&amp;nbsp;&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("$SAMPLE_DATA\Big Class.jmp");

some_func = function({dt, list_x, list_y, list_group_x={}}, 
	{varExpr, i}, 
	varExpr=Expr(Variables());
	for(i=1, i&amp;lt;=nitems(list_x), i++,
		insert into(varExpr, EvalExpr(X(Expr(list_x[i]))));
	);
	for(i=1, i&amp;lt;=nitems(list_y), i++,
		insert into(varExpr, EvalExpr(Y(Expr(list_y[i]))));
	);
	for(i=1, i&amp;lt;=nitems(list_group_x), i++,
		insert into(varExpr, EvalExpr(Group X(Expr(list_group_x[i]))));
	);
	Eval(Substitute(
		Expr(
			dt &amp;lt;&amp;lt; Graph Builder(
				Size( 696, 578 ),
				DV_VARS
			)
		), 
		Expr(DV_VARS), nameexpr(varExpr)
	))
);
some_func(dt, {:weight}, {:height, :height});
some_func(dt, {:weight, :weight}, {:height}, {:age});&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 May 2023 19:51:53 GMT</pubDate>
    <dc:creator>vince_faller</dc:creator>
    <dc:date>2023-05-03T19:51:53Z</dc:date>
    <item>
      <title>How do replace contents in the function with a placeholder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/627075#M82573</link>
      <description>&lt;P&gt;The First chunk of code is how ill like it to work but it doesnt.&lt;/P&gt;&lt;P&gt;The Second chunk of code works if i replace Variables( vars ) with it&lt;/P&gt;&lt;P&gt;Is there a way to get the First chunk working? Please advise if im doing something wrong here thankyou. JMP16&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;		//Define variables for X, X1, X2, Y, Y1, Y2, and Group X
		vars = {X(colX[i]), X(colX1[i], Position( 1 )), X(colX2[i], Position( 1 )),
				Y(colY[i]), Y(colY1[i], Position( 1 )), Y(colY2[i], Position( 1 ))&lt;BR /&gt;        };&lt;BR /&gt;&lt;BR /&gt;        //If colGroupX[i] is not missing, add Group X statement to the variables block
		If( Is Missing(colGroupX[i]) != 1, 
			vars = Insert Into( vars, Group X( colGroupX[i] ) )
		);&lt;BR /&gt;&lt;BR /&gt;// Graph builder code where vars is inserted into the variables &lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;                GB = Current Data Table() &amp;lt;&amp;lt; Graph Builder(
					Size( 1413, 999 ),
					Variables( vars ), // vars is placed here
					Elements(
						Points( X( 1 ), X( 2 ), X( 3 ), Y( 1 ), Y( 2 ), Legend( 11 ) ),
						Smoother( X( 1 ), X( 2 ), Y( 3 ), Y( 1 ), Y( 2 ), Legend( 14 ) )
					),					
					SendToReport(
						Dispatch(
							{},
							"Graph",
							ScaleBox,
							{Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
						)
					)
					
				);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Variables(&lt;BR /&gt;X(colX[i]),&lt;BR /&gt;X(colX1[i], Position( 1 )),&lt;BR /&gt;X(colX2[i], Position( 1 )),&lt;BR /&gt;Y(colY[i]),&lt;BR /&gt;Y(colY1[i], Position( 1 )),&lt;BR /&gt;Y(colY2[i], Position( 1 ))&lt;BR /&gt;),&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:09:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/627075#M82573</guid>
      <dc:creator>Dyan</dc:creator>
      <dc:date>2023-06-09T16:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do replace contents in the function with a placeholder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/627117#M82574</link>
      <description>&lt;P&gt;Check out Expressions -- you need to use expressions to do this.&amp;nbsp; Here is an example that should work for you:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Define variables for X, X1, X2, Y, Y1, Y2, and Group X
vars = {X(colX[i]), X(colX1[i], Position( 1 )), X(colX2[i], Position( 1 ))
,
		Y(colY[i]), Y(colY1[i], Position( 1 )), Y(colY2[i], Position( 1 ))
};

		
If( Is Missing(colGroupX[i]) != 1, 
	vars = Insert Into( vars, Group X( colGroupX[i] ) )
);

	
vars = Substitute( vars, {}, Expr( Variables() ) );

Eval( Eval Expr(
GB = Current Data Table() &amp;lt;&amp;lt; Graph Builder(
	Size( 1413, 999 ),
	Expr( Name Expr( vars ) ),
	Elements(
		Points( X( 1 ), X( 2 ), X( 3 ), Y( 1 ), Y( 2 ), Legend( 11 ) ),
		Smoother( X( 1 ), X( 2 ), Y( 3 ), Y( 1 ), Y( 2 ), Legend( 14 ) )
	),
	SendToReport(
		Dispatch( {}, "Graph", ScaleBox,
			{Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 )} )}
		)
	)
)
) )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Apr 2023 06:54:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/627117#M82574</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2023-04-28T06:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do replace contents in the function with a placeholder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/627840#M82623</link>
      <description>&lt;P&gt;Thanks for your reply, using what you have sent i tried to create a version of my own where it will add into vars if its not empty&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&amp;nbsp;       vars = {};	
		If( Is Missing(colX[i]) != 1, Insert Into( vars, X(colX[i])));
		If(	Is Missing(colX1[i]) != 1, Insert Into( vars, X(colX1[i], Position( 1 ))));
		If(	Is Missing(colX2[i]) != 1, Insert Into( vars, X(colX2[i], Position( 1 ))));
		If(	Is Missing(colX3[i]) != 1, Insert Into( vars, X(colX3[i], Position( 1 ))));
		If(	Is Missing(colX4[i]) != 1, Insert Into( vars, X(colX4[i], Position( 1 )))); 

		If( Is Missing(colY[i]) != 1, Insert Into( vars, Y(colY[i])));  
		If(	Is Missing(colY1[i]) != 1, Insert Into( vars, Y(colY1[i], Position( 1 ))));
		If(	Is Missing(colY2[i]) != 1, Insert Into( vars, Y(colY2[i], Position( 1 ))));
		If(	Is Missing(colY3[i]) != 1, Insert Into( vars, Y(colY3[i], Position( 1 ))));
		If(	Is Missing(colY4[i]) != 1, Insert Into( vars, Y(colY4[i], Position( 1 )))); &lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;If( Is Missing(colGroupX[i]) != 1, Insert Into( vars, Group X(colGroupX[i])));&lt;/PRE&gt;&lt;P&gt;When i run it, it will have an error&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name Unresolved: X in access or evaluation of 'X' , X( colX[i] ) /*###*/&lt;/P&gt;&lt;P&gt;But if i include into the vars statement below it works&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;vars = {X(colX[i]), X(colX1[i], Position( 1 )), X(colX2[i], Position( 1 ))
,
		Y(colY[i]), Y(colY1[i], Position( 1 )), Y(colY2[i], Position( 1 ))
};&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise thankyou !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 01:20:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/627840#M82623</guid>
      <dc:creator>Dyan</dc:creator>
      <dc:date>2023-05-02T01:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do replace contents in the function with a placeholder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/628028#M82637</link>
      <description>&lt;P&gt;You need to insert expressions into the list.&amp;nbsp; With the prototype &lt;CODE class=" language-jsl"&gt;Insert Into( var, value, position )&lt;/CODE&gt;, JMP will only perform a name-lookup on &lt;CODE class=" language-jsl"&gt;var&lt;/CODE&gt; (will not try to evaluate whatever is returned from the name lookup), will perform a name lookup and evaluate &lt;CODE class=" language-jsl"&gt;value&lt;/CODE&gt;, and will perform a name lookup and evaluate &lt;CODE class=" language-jsl"&gt;position&lt;/CODE&gt;.&amp;nbsp; You want to insert an expression into the list -- thus you don't want JMP to evaluate whatever you've placed into the &lt;CODE class=" language-jsl"&gt;value&lt;/CODE&gt; position.&amp;nbsp; JMP will _always_ evaluate it however, so to keep an expression even though JMP evaluates it, wrap it in an &lt;CODE class=" language-jsl"&gt;Expr()&lt;/CODE&gt; function, like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;        vars = {};	
		If( Is Missing(colX[i]) != 1, Insert Into( vars, Expr( X(colX[i]) )));
		If(	Is Missing(colX1[i]) != 1, Insert Into( vars, Expr( X(colX1[i], Position( 1 )) )));
		If(	Is Missing(colX2[i]) != 1, Insert Into( vars, Expr( X(colX2[i], Position( 1 )) )));
		If(	Is Missing(colX3[i]) != 1, Insert Into( vars, Expr( X(colX3[i], Position( 1 )) )));
		If(	Is Missing(colX4[i]) != 1, Insert Into( vars, Expr( X(colX4[i], Position( 1 )) ))); 

		If( Is Missing(colY[i]) != 1, Insert Into( vars, Expr( Y(colY[i]) )));  
		If(	Is Missing(colY1[i]) != 1, Insert Into( vars, Expr( Y(colY1[i], Position( 1 )) )));
		If(	Is Missing(colY2[i]) != 1, Insert Into( vars, Expr( Y(colY2[i], Position( 1 )) )));
		If(	Is Missing(colY3[i]) != 1, Insert Into( vars, Expr( Y(colY3[i], Position( 1 )) )));
		If(	Is Missing(colY4[i]) != 1, Insert Into( vars, Expr( Y(colY4[i], Position( 1 )) ))); 
If( Is Missing(colGroupX[i]) != 1, Insert Into( vars, Expr( Group X(colGroupX[i]) )));&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 20:59:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/628028#M82637</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2023-05-02T20:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do replace contents in the function with a placeholder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/628331#M82664</link>
      <description>&lt;P&gt;Are you really trying to just make graph builder dynamic?&amp;nbsp; Something like this?&amp;nbsp;&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("$SAMPLE_DATA\Big Class.jmp");

some_func = function({dt, list_x, list_y, list_group_x={}}, 
	{varExpr, i}, 
	varExpr=Expr(Variables());
	for(i=1, i&amp;lt;=nitems(list_x), i++,
		insert into(varExpr, EvalExpr(X(Expr(list_x[i]))));
	);
	for(i=1, i&amp;lt;=nitems(list_y), i++,
		insert into(varExpr, EvalExpr(Y(Expr(list_y[i]))));
	);
	for(i=1, i&amp;lt;=nitems(list_group_x), i++,
		insert into(varExpr, EvalExpr(Group X(Expr(list_group_x[i]))));
	);
	Eval(Substitute(
		Expr(
			dt &amp;lt;&amp;lt; Graph Builder(
				Size( 696, 578 ),
				DV_VARS
			)
		), 
		Expr(DV_VARS), nameexpr(varExpr)
	))
);
some_func(dt, {:weight}, {:height, :height});
some_func(dt, {:weight, :weight}, {:height}, {:age});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 May 2023 19:51:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/628331#M82664</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2023-05-03T19:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do replace contents in the function with a placeholder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/628403#M82674</link>
      <description>&lt;P&gt;Hi vince thanks for anwsering, this looks great. However, how do u change the type of plot to etc Line of fit or bar plot since the above method only works for smoother type plot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 09:30:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-replace-contents-in-the-function-with-a-placeholder/m-p/628403#M82674</guid>
      <dc:creator>Dyan</dc:creator>
      <dc:date>2023-05-04T09:30:48Z</dc:date>
    </item>
  </channel>
</rss>

