<?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 make a JMP script to make a new window for user input assigning values to a col based on another col in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419713#M66868</link>
    <description>&lt;P&gt;For sure - that's something I thought about doing before I got stuck. But I want to have an application for people who don't know the JMP interface very well.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Sep 2021 17:40:26 GMT</pubDate>
    <dc:creator>kachveder</dc:creator>
    <dc:date>2021-09-21T17:40:26Z</dc:date>
    <item>
      <title>How to make a JMP script to make a new window for user input assigning values to a col based on another col</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419045#M66805</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stuck on a specific part of my JMP script and am hoping to get some help from a different set of eyes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that looks like this, but with a lot more categories, each with longer names.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kachveder_1-1631903862033.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35903iFB4835C36DA690AC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kachveder_1-1631903862033.png" alt="kachveder_1-1631903862033.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to create another column, with numeric values, based on the given column. This product needs to be fully automated, with a pop-up window with each of the categories listed out, with number edit boxes that the user can input the numeric values that will correspond to a category. For example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pop-up window box: new window with all prompts in the pop-up window box.&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Enter value corresponding to A:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;___1___&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Enter value corresponding to B:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;___2___&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Enter value corresponding to C:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;___3___&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Enter value corresponding to D:&lt;/img&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;___4___&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Enter value corresponding to E:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;___5___&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The resulting data table should look like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kachveder_2-1631904547962.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35904i5ED64D4CDFF666CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kachveder_2-1631904547962.png" alt="kachveder_2-1631904547962.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the JMP script that I have right now. I have also uploaded the JMP file to this post. What I need help with is in&lt;FONT color="#FF0000"&gt; red text&lt;/FONT&gt; below. I am having trouble assigning the ith value in the for loop, based on user input and corresponding to the ith unique category in the list,&amp;nbsp;&lt;CODE class=" language-jsl"&gt;unique_char&lt;/CODE&gt;, to the ith position in the initialized numeric list,&amp;nbsp;&lt;CODE class=" language-jsl"&gt;num_list&lt;/CODE&gt;, which will be used later in the next for loop for creating the column 2 (at the end of the JMP script below).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

//get the unique character variable list
Names Default To Here( 1 );
col9 = Column(dt, "Column 1");
unique_char = Associative Array(col9) &amp;lt;&amp;lt; get keys; // unique_char = {"A", "B", "C", "D", "E"}

//get n items in character variable list
nuniquechar = N Items(unique_char); //will be 5, if categories are A, B, C, D, E

//initalize number list
num_list = {};

//create new window to create multiple number edit boxes
nw = New Window( "Set Values",
&amp;lt;&amp;lt;Modal,

// Make the for loop of for every item in nuniquechar list, 
// ask and save user input for the LSL in a element of the num_list list
	for (i = 1, 
		i &amp;lt;= nuniquechar, 
		i++,
		Text Box("Number for " || unique_char[i] || ":"),   //i.e. "Number for A:"
		
&lt;FONT color="#FF0000"&gt;		// HELP: 
		// name a numeric variable on each iteration that will be the holder of a numeric edit box
		// put the resulting ith entry into the num_list
		num_list[i] = number edit box(),&lt;/FONT&gt; 
			// number box default is null/missing. If no input, place a missing value in the num_list
		
		
	)
	
);&lt;BR /&gt;&lt;BR /&gt;// TO DO: &lt;BR /&gt;// Create new column assigning the num_list values to &lt;BR /&gt;// the corresponding rows based the unique character value. &lt;BR /&gt;// Pseudo-code: &lt;BR /&gt;// for(i in 1:nuniquechar)&lt;BR /&gt;// if :column 1 = unique_char[i], num_list[i]&lt;BR /&gt;//&lt;BR /&gt;//&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The results from this will be the automated and user-friendly version of using the following conditional logic to make column 2 based on column 1's categories.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kachveder_3-1631904996827.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35905i5722FBFE2406CB2E/image-size/large?v=v2&amp;amp;px=999" role="button" title="kachveder_3-1631904996827.png" alt="kachveder_3-1631904996827.png" /&gt;&lt;/span&gt;&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:37:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419045#M66805</guid>
      <dc:creator>kachveder</dc:creator>
      <dc:date>2023-06-10T23:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a JMP script to make a new window for user input assigning values to a col based on another col</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419141#M66812</link>
      <description>&lt;P&gt;I'm using &amp;lt;&amp;lt; Set Function with the number edit box to get the values to unique_aa associative array. Then using that associative array to build the formula column needed, after closing the modal window.&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();

//get the unique character variable list
col9 = Column(dt, "Column 1");
unique_char = Associative Array(col9) &amp;lt;&amp;lt; get keys;
nuniquechar = N Items(unique_char); //will be 5, if categories are A, B, C, D, E
unique_aa = Associative Array(unique_char, Repeat({.}, nuniquechar)); //repeat to initialize values as missing

//create new window to create multiple number edit boxes
vlbExpr = V List Box();
For(i = 1, i &amp;lt;= nuniquechar, i++,
	Insert Into(vlbExpr, Text Box("Number for " || Char(unique_char[i]) || ":"));   //i.e. "Number for A:"
	Eval(
		Eval Expr(Insert Into(vlbExpr, Number Edit Box(., &amp;lt;&amp;lt;Set Function(Function({this}, unique_aa[Expr(unique_char[i])] = this &amp;lt;&amp;lt; get)))))
	);
);

nw = New Window("Set Values",
	&amp;lt;&amp;lt;Modal,
	vlbExpr,
	H List Box(
		Button Box("OK", 
		
		),
		Button Box("Cancel")
	)
);
//Show(unique_aa);

Eval(EvalExpr(dt &amp;lt;&amp;lt; New Column("Column 2",
	Numeric,
	Continuous,
	&amp;lt;&amp;lt; Formula(
		Expr(unique_aa)[:Column 1]
	);
)));

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For information about Eval(EvalExpr()) see &lt;A href="https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/ta-p/48998" target="_blank" rel="noopener"&gt;Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute&lt;/A&gt; . And if you want to have formula&lt;/P&gt;</description>
      <pubDate>Sat, 18 Sep 2021 07:47:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419141#M66812</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-09-18T07:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a JMP script to make a new window for user input assigning values to a col based on another col</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419142#M66813</link>
      <description>&lt;P&gt;Here is a little script that I put together -- not you may want an optional selector to make the new column numeric (here I just leave it as character).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have to enter a new column name and there is a check to not run if the new name exists in the data table currently (I know JMP wont overwrite a column, but it can still be confusing).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/* recode */

self = New Namespace();
Show( self &amp;lt;&amp;lt; Get Name );

self:table = Current Data Table();
self:column = Insert( {}, self:table &amp;lt;&amp;lt; Get Selected Columns );
self:column = self:column[1] &amp;lt;&amp;lt; Get Name;
Show( self:column );
self:values = Associative Array( Column( self:table, self:column ) ) &amp;lt;&amp;lt; Get Keys;

self:string list = {};
For( i = 1, i &amp;lt;= N Items( self:values ), i++,
	Insert Into( self:string list, Char( i ) )
);

Eval( Eval Expr(

win = New Window( "Set Values",
	&amp;lt;&amp;lt;Modal
,
	&amp;lt;&amp;lt;On Validate(
		self = Namespace( Expr( self &amp;lt;&amp;lt; Get Name ) );
		return = 1;
		If( Glue( name = Trim( self:name box &amp;lt;&amp;lt; Get Text ) ) == "",
			New Window( "Error",
				&amp;lt;&amp;lt;Modal,
				Text Box( "Please enter a name for the new column" )
			);
			return = 0;
		);
		If( return,
			lookup = Associative Array( self:values, self:recode box &amp;lt;&amp;lt; Get );
			::__dunder_mifflin__ = lookup;
			names = self:table &amp;lt;&amp;lt; Get Column Names( "String" );
			If( Contains( names, name ),
				New Window( "Error",
					&amp;lt;&amp;lt;Modal,
					Text Box( "Error, data table already contains column \!"" || name || "\!", please use a different name" )
				);
				return = 0;
			);
		);
		If( return,
			Eval( Parse( Eval Insert( JSL Quote(
				self:table &amp;lt;&amp;lt; New Column( name, "Character", &amp;lt;&amp;lt;Set Each Value( ::__dunder_mifflin__[:Name("^self:column^")] ) )
			) ) ) );
		);
		return
	)
,
	&amp;lt;&amp;lt;On Close(
		self = Namespace( Expr( self &amp;lt;&amp;lt; Get Name ) );
		self &amp;lt;&amp;lt; Delete Namespace();
		1
	)
,
	self = Namespace( Expr( self &amp;lt;&amp;lt; Get Name ) );
	V List Box(
		self:name box = Text Edit Box( "", &amp;lt;&amp;lt;Set Hint( "Column Name" ) )
	,
		Table Box(
			String Col Box( "Current",
				self:values
			)
		,
			self:recode box = String Col Edit Box( "Recode",
				self:string list
			)
		)
	)
)

) );

0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Sep 2021 08:08:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419142#M66813</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2021-09-18T08:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a JMP script to make a new window for user input assigning values to a col based on another col</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419455#M66842</link>
      <description>&lt;P&gt;Have you considered the &lt;STRONG&gt;Cols &amp;gt; Recode&lt;/STRONG&gt; platform?&amp;nbsp; Might be a good low-tech way to do what you want.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 17:40:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419455#M66842</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2021-09-20T17:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a JMP script to make a new window for user input assigning values to a col based on another col</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419713#M66868</link>
      <description>&lt;P&gt;For sure - that's something I thought about doing before I got stuck. But I want to have an application for people who don't know the JMP interface very well.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 17:40:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-a-JMP-script-to-make-a-new-window-for-user-input/m-p/419713#M66868</guid>
      <dc:creator>kachveder</dc:creator>
      <dc:date>2021-09-21T17:40:26Z</dc:date>
    </item>
  </channel>
</rss>

