<?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 Using Number Edit Boxes to change Spec Limits in Column Properties and Column Formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-Number-Edit-Boxes-to-change-Spec-Limits-in-Column/m-p/620278#M81951</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the following script to define in a pop-up window the lower and upper spec limits (LSL and USL) and use the values in order to set the column properties for the spec limits. On top of that, I have a formula column called "check", where I want to use the values within the formula to check if the value in the row is within the spec ranges or not.&lt;/P&gt;&lt;P&gt;The code is running but the values are not entered for the spec limits or in the formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="jsl"&gt;// Just some code to create a test tableNew Table( "test",
	Add Rows( 10 ),
	New Column( "LA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[4172.33500363846, 4003.0454164522, 5132.51142953179, 4254.16795732848,
			4202.75172580535, 3574.47256743923, 3804.96534319603, 3915.70034276743,
			4319.47567126139, 4094.59235385003]
		),
		Set Display Width( 73 )
	),
	New Column( "UA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[59507.3313010261, 53541.4856212676, 71149.6162777807, 59578.8338627777,
			56630.4195099436, 50900.019384575, 51479.1947874623, 53642.2158390849,
			61673.2466126228, 56337.4407587715]
		),
		Set Display Width( 73 )
	),
	New Column( "95CIupr SD LA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[1043.86456772353, 876.888513223994, 1136.27463369684, 970.028749878648,
			954.598082854551, 941.489444193772, 846.345601078669, 801.488231630083,
			973.917277695926, 934.431089864531]
		),
		Set Display Width( 81 )
	),
	New Column( "95CIupr SD UA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[3068.69934323136, 2352.88265793793, 4263.23712733597, 2974.99490133574,
			2684.01670727501, 2048.97811082407, 2128.8899692482, 2298.27809836615,
			3264.19929423158, 2671.90896127954]
		),
		Set Display Width( 83 )
	)
)


//define default values for number edit boxes
UA_LSL = 0.8; // numbers with default
UA_USL = 1.2; // number with default
UA_LA_LSL = 0.8; // number with default
UA_LA_USL = 1.2; // number with default



//code for the pop-up window

w = New Window( "SST simulation", &amp;lt;&amp;lt;modal, // opens a window with a title and this content...
	Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box( Text Box( "Define SST Options" ) ), // a second title, centered
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "UA1/UA2 LSL and USL: " ), meta_UA_LSL = Number Edit Box( UA_LSL ), meta_UA_USL = Number Edit Box( UA_USL ) ), // data entry
			Spacer Box(size(1, 10)),
			H List Box( Text Box( "UA1-LA1/UA2-LA2 LSL and USL: " ), meta_UA_LA_LSL = Number Edit Box( UA_LA_LSL ), meta_UA_LA_USL = Number Edit Box( UA_LA_USL ) ), // data entry
			Spacer Box(size(1, 10)),
			H List Box( // center the button
				Button Box( "OK", // this script runs when the button is pressed...
					UA_LSL = meta_UA_LSL &amp;lt;&amp;lt; get;
					UA_USL = meta_UA_USL &amp;lt;&amp;lt; get;
					UA_LA_LSL = meta_UA_LA_LSL &amp;lt;&amp;lt; get;
					UA_LA_USL = meta_UA_LA_USL &amp;lt;&amp;lt; get;
					),
					Spacer Box(size(10, 1)),
				Button Box("Cancel")
					//w &amp;lt;&amp;lt; closeWindow; // close the dialog
				)
			)
		)
	);

// If cancel or X was clicked, stop the script
If( w == {Button( -1 )}, Stop() );	


//code to  to change spec limits in column properties and column formulas
dt = Current Data Table();


// Paste columns
dt &amp;lt;&amp;lt; New Column( "UA1/UA2",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Set Property(
		"Spec Limits",
		{LSL( UA_LSL ), USL( UA_USL ), Target( 1 ), Show Limits( 1 )}
	),
	Formula(
		Random Normal( :UA, :"95CIupr SE UA n = 2"n ) /
		Random Normal( :UA, :"95CIupr SE UA n = 2"n )
	),
	Set Selected,
	Set Display Width( 73 )
) &amp;lt;&amp;lt; New Column( "UA1-LA1/UA2-LA2",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Set Property(
		"Spec Limits",
		{LSL( print(UA_LA_LSL) ), USL( UA_LA_USL ), Target( 1 ), Show Limits( 1 )}
	),
	Formula(
		(Random Normal( :UA, :"95CIupr SE UA n = 2"n )
		-Random Normal( :LA, :"95CIupr SE LA n = 2"n )) / (
		Random Normal( :UA, :"95CIupr SE UA n = 2"n )
		-Random Normal( :LA, :"95CIupr SE LA n = 2"n ))
	),
	Set Selected,
	Set Display Width( 106 )
) &amp;lt;&amp;lt; New Column( "Check",
	Character( 7 ),
	"Nominal",
	Formula(
		If(
			:"UA1/UA2"n &amp;lt; UA_LSL | :"UA1/UA2"n
			 &amp;gt; UA_USL | :"UA1-LA1/UA2-LA2"n &amp;lt; UA_LA_LSL | :"UA1-LA1/UA2-LA2"n &amp;gt; UA_LA_USL,
			"Outside",
			"Inside"
		)
	),
	Set Selected,
	Set Display Width( 50 )
);


&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greetings&lt;/P&gt;&lt;P&gt;/Marco&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 16:07:21 GMT</pubDate>
    <dc:creator>Marco_</dc:creator>
    <dc:date>2023-06-09T16:07:21Z</dc:date>
    <item>
      <title>Using Number Edit Boxes to change Spec Limits in Column Properties and Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-Number-Edit-Boxes-to-change-Spec-Limits-in-Column/m-p/620278#M81951</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the following script to define in a pop-up window the lower and upper spec limits (LSL and USL) and use the values in order to set the column properties for the spec limits. On top of that, I have a formula column called "check", where I want to use the values within the formula to check if the value in the row is within the spec ranges or not.&lt;/P&gt;&lt;P&gt;The code is running but the values are not entered for the spec limits or in the formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="jsl"&gt;// Just some code to create a test tableNew Table( "test",
	Add Rows( 10 ),
	New Column( "LA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[4172.33500363846, 4003.0454164522, 5132.51142953179, 4254.16795732848,
			4202.75172580535, 3574.47256743923, 3804.96534319603, 3915.70034276743,
			4319.47567126139, 4094.59235385003]
		),
		Set Display Width( 73 )
	),
	New Column( "UA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[59507.3313010261, 53541.4856212676, 71149.6162777807, 59578.8338627777,
			56630.4195099436, 50900.019384575, 51479.1947874623, 53642.2158390849,
			61673.2466126228, 56337.4407587715]
		),
		Set Display Width( 73 )
	),
	New Column( "95CIupr SD LA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[1043.86456772353, 876.888513223994, 1136.27463369684, 970.028749878648,
			954.598082854551, 941.489444193772, 846.345601078669, 801.488231630083,
			973.917277695926, 934.431089864531]
		),
		Set Display Width( 81 )
	),
	New Column( "95CIupr SD UA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[3068.69934323136, 2352.88265793793, 4263.23712733597, 2974.99490133574,
			2684.01670727501, 2048.97811082407, 2128.8899692482, 2298.27809836615,
			3264.19929423158, 2671.90896127954]
		),
		Set Display Width( 83 )
	)
)


//define default values for number edit boxes
UA_LSL = 0.8; // numbers with default
UA_USL = 1.2; // number with default
UA_LA_LSL = 0.8; // number with default
UA_LA_USL = 1.2; // number with default



//code for the pop-up window

w = New Window( "SST simulation", &amp;lt;&amp;lt;modal, // opens a window with a title and this content...
	Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box( Text Box( "Define SST Options" ) ), // a second title, centered
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "UA1/UA2 LSL and USL: " ), meta_UA_LSL = Number Edit Box( UA_LSL ), meta_UA_USL = Number Edit Box( UA_USL ) ), // data entry
			Spacer Box(size(1, 10)),
			H List Box( Text Box( "UA1-LA1/UA2-LA2 LSL and USL: " ), meta_UA_LA_LSL = Number Edit Box( UA_LA_LSL ), meta_UA_LA_USL = Number Edit Box( UA_LA_USL ) ), // data entry
			Spacer Box(size(1, 10)),
			H List Box( // center the button
				Button Box( "OK", // this script runs when the button is pressed...
					UA_LSL = meta_UA_LSL &amp;lt;&amp;lt; get;
					UA_USL = meta_UA_USL &amp;lt;&amp;lt; get;
					UA_LA_LSL = meta_UA_LA_LSL &amp;lt;&amp;lt; get;
					UA_LA_USL = meta_UA_LA_USL &amp;lt;&amp;lt; get;
					),
					Spacer Box(size(10, 1)),
				Button Box("Cancel")
					//w &amp;lt;&amp;lt; closeWindow; // close the dialog
				)
			)
		)
	);

// If cancel or X was clicked, stop the script
If( w == {Button( -1 )}, Stop() );	


//code to  to change spec limits in column properties and column formulas
dt = Current Data Table();


// Paste columns
dt &amp;lt;&amp;lt; New Column( "UA1/UA2",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Set Property(
		"Spec Limits",
		{LSL( UA_LSL ), USL( UA_USL ), Target( 1 ), Show Limits( 1 )}
	),
	Formula(
		Random Normal( :UA, :"95CIupr SE UA n = 2"n ) /
		Random Normal( :UA, :"95CIupr SE UA n = 2"n )
	),
	Set Selected,
	Set Display Width( 73 )
) &amp;lt;&amp;lt; New Column( "UA1-LA1/UA2-LA2",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Set Property(
		"Spec Limits",
		{LSL( print(UA_LA_LSL) ), USL( UA_LA_USL ), Target( 1 ), Show Limits( 1 )}
	),
	Formula(
		(Random Normal( :UA, :"95CIupr SE UA n = 2"n )
		-Random Normal( :LA, :"95CIupr SE LA n = 2"n )) / (
		Random Normal( :UA, :"95CIupr SE UA n = 2"n )
		-Random Normal( :LA, :"95CIupr SE LA n = 2"n ))
	),
	Set Selected,
	Set Display Width( 106 )
) &amp;lt;&amp;lt; New Column( "Check",
	Character( 7 ),
	"Nominal",
	Formula(
		If(
			:"UA1/UA2"n &amp;lt; UA_LSL | :"UA1/UA2"n
			 &amp;gt; UA_USL | :"UA1-LA1/UA2-LA2"n &amp;lt; UA_LA_LSL | :"UA1-LA1/UA2-LA2"n &amp;gt; UA_LA_USL,
			"Outside",
			"Inside"
		)
	),
	Set Selected,
	Set Display Width( 50 )
);


&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greetings&lt;/P&gt;&lt;P&gt;/Marco&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:07:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-Number-Edit-Boxes-to-change-Spec-Limits-in-Column/m-p/620278#M81951</guid>
      <dc:creator>Marco_</dc:creator>
      <dc:date>2023-06-09T16:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using Number Edit Boxes to change Spec Limits in Column Properties and Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-Number-Edit-Boxes-to-change-Spec-Limits-in-Column/m-p/620475#M81972</link>
      <description>&lt;P&gt;I found a couple of issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, in your formula columns, you were specifying SE, and in your data table, the columns have SD.&amp;nbsp; Also in the formulas, there was&amp;nbsp; &amp;nbsp; &amp;nbsp; n = 2, referenced as part of the column name.&amp;nbsp; I don't know where that is coming from, so I just removed it, and the creation of the column formulas work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the values in the Spec Limits lists need to be fully expanded before the Set Property will work.&amp;nbsp; Using a Substitute to pass in the limits values into the list is one way to do this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=new table("example",
// Just some code to create a test tableNew Table( "test",
	Add Rows( 10 ),
	New Column( "LA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[4172.33500363846, 4003.0454164522, 5132.51142953179, 4254.16795732848,
			4202.75172580535, 3574.47256743923, 3804.96534319603, 3915.70034276743,
			4319.47567126139, 4094.59235385003]
		),
		Set Display Width( 73 )
	),
	New Column( "UA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[59507.3313010261, 53541.4856212676, 71149.6162777807, 59578.8338627777,
			56630.4195099436, 50900.019384575, 51479.1947874623, 53642.2158390849,
			61673.2466126228, 56337.4407587715]
		),
		Set Display Width( 73 )
	),
	New Column( "95CIupr SD LA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[1043.86456772353, 876.888513223994, 1136.27463369684, 970.028749878648,
			954.598082854551, 941.489444193772, 846.345601078669, 801.488231630083,
			973.917277695926, 934.431089864531]
		),
		Set Display Width( 81 )
	),
	New Column( "95CIupr SD UA",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[3068.69934323136, 2352.88265793793, 4263.23712733597, 2974.99490133574,
			2684.01670727501, 2048.97811082407, 2128.8899692482, 2298.27809836615,
			3264.19929423158, 2671.90896127954]
		),
		Set Display Width( 83 )
	)
);


//define default values for number edit boxes
UA_LSL = 0.8; // numbers with default
UA_USL = 1.2; // number with default
UA_LA_LSL = 0.8; // number with default
UA_LA_USL = 1.2; // number with default



//code for the pop-up window

w = New Window( "SST simulation", &amp;lt;&amp;lt;modal, // opens a window with a title and this content...
	Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box( Text Box( "Define SST Options" ) ), // a second title, centered
			Spacer Box( size( 1, 30 ) ), // a little vertical space
			H List Box( Text Box( "UA1/UA2 LSL and USL: " ), meta_UA_LSL = Number Edit Box( UA_LSL ), meta_UA_USL = Number Edit Box( UA_USL ) ), // data entry
			Spacer Box(size(1, 10)),
			H List Box( Text Box( "UA1-LA1/UA2-LA2 LSL and USL: " ), meta_UA_LA_LSL = Number Edit Box( UA_LA_LSL ), meta_UA_LA_USL = Number Edit Box( UA_LA_USL ) ), // data entry
			Spacer Box(size(1, 10)),
			H List Box( // center the button
				Button Box( "OK", // this script runs when the button is pressed...
					UA_LSL = meta_UA_LSL &amp;lt;&amp;lt; get;
					UA_USL = meta_UA_USL &amp;lt;&amp;lt; get;
					UA_LA_LSL = meta_UA_LA_LSL &amp;lt;&amp;lt; get;
					UA_LA_USL = meta_UA_LA_USL &amp;lt;&amp;lt; get;
					),
					Spacer Box(size(10, 1)),
				Button Box("Cancel")
					//w &amp;lt;&amp;lt; closeWindow; // close the dialog
				)
			)
		)
	);

// If cancel or X was clicked, stop the script
If( w == {Button( -1 )}, Stop() );	


//code to  to change spec limits in column properties and column formulas
//dt = Current Data Table();


// Paste columns
Eval(
	Substitute(
			Expr(
				dt &amp;lt;&amp;lt; New Column( "UA1/UA2",
					Numeric,
					"Continuous",
					Format( "Best", 12 ),
					Set Property(
						"Spec Limits",
						Eval( {LSL( _UA_LSL_ ), USL( _UA_USL_ ), Target( 1 ), Show Limits( 1 )} )
					),
					Formula(
						Random Normal( :UA, :"95CIupr SD UA"n   ) /
						Random Normal( :UA, :"95CIupr SD UA"n  )
					),
					Set Selected,
					Set Display Width( 73 )
				)
			),
		Expr( _UA_LSL_ ), UA_LSL,
		Expr( _UA_USL_ ), UA_USL
	)
);
Eval(
	Substitute(
			Expr(
				dt &amp;lt;&amp;lt; New Column( "UA1-LA1/UA2-LA2",
					Numeric,
					"Continuous",
					Format( "Best", 12 ),
					Set Property(
						"Spec Limits",
						{LSL( _UA_LA_LSL_ ), USL( _UA_LA_USL_ ), Target( 1 ), Show Limits( 1 )}
					),
					Formula(
						(Random Normal( :UA, :"95CIupr SD UA"n )
						-Random Normal( :LA, :"95CIupr SD LA"n )) / (
						Random Normal( :UA, :"95CIupr SD UA"n )
						-Random Normal( :LA, :"95CIupr SD LA"n ))
					),
					Set Selected,
					Set Display Width( 106 )
				)
			),
		Expr( _UA_LA_LSL_ ), UA_LA_LSL,
		Expr( _UA_LA_USL_ ), UA_LA_USL
	)
);
dt &amp;lt;&amp;lt; New Column( "Check",
	Character( 7 ),
	"Nominal",
	Formula(
		If(
			:"UA1/UA2"n &amp;lt; UA_LSL | :"UA1/UA2"n
			 &amp;gt; UA_USL | :"UA1-LA1/UA2-LA2"n &amp;lt; UA_LA_LSL | :"UA1-LA1/UA2-LA2"n &amp;gt; UA_LA_USL,
			"Outside",
			"Inside"
		)
	),
	Set Selected,
	Set Display Width( 50 )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Apr 2023 06:01:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-Number-Edit-Boxes-to-change-Spec-Limits-in-Column/m-p/620475#M81972</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-04-06T06:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using Number Edit Boxes to change Spec Limits in Column Properties and Column Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Using-Number-Edit-Boxes-to-change-Spec-Limits-in-Column/m-p/620598#M81976</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!!! Your code works like a charm! Sorry for the "n=2" part, this was a leftover from my original code ;)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 14:28:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-Number-Edit-Boxes-to-change-Spec-Limits-in-Column/m-p/620598#M81976</guid>
      <dc:creator>Marco_</dc:creator>
      <dc:date>2023-04-06T14:28:50Z</dc:date>
    </item>
  </channel>
</rss>

