<?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 I search for unique values in column and use in input window? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52761#M29880</link>
    <description>&lt;P&gt;Welcome to the community.&lt;/P&gt;
&lt;P&gt;First, I have a suggestion on how to speed up your learning of JSL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;Read the Scripting Guide!!!!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It is available at&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 barebones script to accomplish what you requested.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "Untitled 2",
	Add Rows( 7 ),
	New Column( "Cup Color",
		Character,
		"Nominal",
		Set Selected,
		Set Values( {"blue", "green", "yellow", "purple", "blue", "blue", "yellow"} )
	),
	New Column( "Calories",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [140, 80, 200, 130, 140, 140, 200] )
	),
	New Column( "Taste",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [4, 7, 2, 3, 3, 4, 5] )
	),
	New Column( "Ranking",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [2, 1, 3, 6, 5, 4, 7] )
	),
	New Column( "Tester",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 4, 6, 4, 2, 3, 1] )
	)
);

// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );

// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i &amp;lt;= N Items( colorList ), i++,
	Insert Into( flavorList, "" )
);

// Create the display window
nw = New Window( "Select Flavors",
	Text Box( "Enter in Flavors for each Color" ),
	tb = Table Box(
		String Col Box( "Colors", colorList ),
		scb = String Col Edit Box( "Flavors", flavorList )
	),
	Button Box( "OK",
		nw &amp;lt;&amp;lt; close window;
		// Create the flavor table and update it to
		// the original table
		dt2 = New Table( "combined",
			New Column( "Cup Color", character, set values( colorList ) ),
			New Column( "Flavors", character, set values( flavorList ) )
		);
		dt &amp;lt;&amp;lt; Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
		close( dt2, nosave );
	)
);
// Set the String Col Edit Box action
scb &amp;lt;&amp;lt; Set Function( Function( {this, which}, flavorList[which] = scb &amp;lt;&amp;lt; get( which ) ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Mar 2018 23:16:22 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-03-07T23:16:22Z</dc:date>
    <item>
      <title>How do I search for unique values in column and use in input window?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52757#M29877</link>
      <description>&lt;P&gt;I have a table that looks something like this, what I would like to do is search the "Cup Color" column for unique values, then have a pop-up window for the user to input a corresponding flavor for each unique cup color...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Cup Color&lt;/TD&gt;&lt;TD&gt;Calories&lt;/TD&gt;&lt;TD&gt;Taste&lt;/TD&gt;&lt;TD&gt;Ranking&lt;/TD&gt;&lt;TD&gt;Tester&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;blue&lt;/TD&gt;&lt;TD&gt;140&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;green&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;purple&lt;/TD&gt;&lt;TD&gt;130&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;blue&lt;/TD&gt;&lt;TD&gt;140&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;blue&lt;/TD&gt;&lt;TD&gt;140&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once we have a flavor for each cup color, I would like to add a new column which is populated based on the the input that we got from the user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;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4&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;cherry&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;yellow&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;chocolate&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still pretty new to JSL and have spent the last several hours going through forums looking for some guidance but can't seem to piece this together, a little help would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 22:32:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52757#M29877</guid>
      <dc:creator>BeefSupreme</dc:creator>
      <dc:date>2018-03-07T22:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search for unique values in column and use in input window?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52761#M29880</link>
      <description>&lt;P&gt;Welcome to the community.&lt;/P&gt;
&lt;P&gt;First, I have a suggestion on how to speed up your learning of JSL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;Read the Scripting Guide!!!!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It is available at&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 barebones script to accomplish what you requested.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "Untitled 2",
	Add Rows( 7 ),
	New Column( "Cup Color",
		Character,
		"Nominal",
		Set Selected,
		Set Values( {"blue", "green", "yellow", "purple", "blue", "blue", "yellow"} )
	),
	New Column( "Calories",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [140, 80, 200, 130, 140, 140, 200] )
	),
	New Column( "Taste",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [4, 7, 2, 3, 3, 4, 5] )
	),
	New Column( "Ranking",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [2, 1, 3, 6, 5, 4, 7] )
	),
	New Column( "Tester",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 4, 6, 4, 2, 3, 1] )
	)
);

// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );

// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i &amp;lt;= N Items( colorList ), i++,
	Insert Into( flavorList, "" )
);

// Create the display window
nw = New Window( "Select Flavors",
	Text Box( "Enter in Flavors for each Color" ),
	tb = Table Box(
		String Col Box( "Colors", colorList ),
		scb = String Col Edit Box( "Flavors", flavorList )
	),
	Button Box( "OK",
		nw &amp;lt;&amp;lt; close window;
		// Create the flavor table and update it to
		// the original table
		dt2 = New Table( "combined",
			New Column( "Cup Color", character, set values( colorList ) ),
			New Column( "Flavors", character, set values( flavorList ) )
		);
		dt &amp;lt;&amp;lt; Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
		close( dt2, nosave );
	)
);
// Set the String Col Edit Box action
scb &amp;lt;&amp;lt; Set Function( Function( {this, which}, flavorList[which] = scb &amp;lt;&amp;lt; get( which ) ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 23:16:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52761#M29880</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-03-07T23:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search for unique values in column and use in input window?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52762#M29881</link>
      <description>Perfect, thanks!</description>
      <pubDate>Wed, 07 Mar 2018 23:44:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52762#M29881</guid>
      <dc:creator>BeefSupreme</dc:creator>
      <dc:date>2018-03-07T23:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search for unique values in column and use in input window?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52825#M29918</link>
      <description>&lt;P&gt;I actually need for my script to wait for the user input before progressing.&lt;/P&gt;&lt;P&gt;I found in the scripting guide that I can do this by using the modal message and thought that I got it added in correctly, but when I run the script I now the table doesn't update - log says "Name Unresolved: Button in access or evaluation of 'Button' , Button( 1 ) /*###*/"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );

// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i &amp;lt;= N Items( colorList ), i++,
	Insert Into( flavorList, "" )
);

// Create the display window
nw = New Window( "Select Flavors",
	&amp;lt;&amp;lt; Modal,
	Text Box( "Enter in Flavors for each Color" ),
	tb = Table Box(
		String Col Box( "Colors", colorList ),
		scb = String Col Edit Box( "Flavors", flavorList )
	),
	Button Box( "OK",
		nw &amp;lt;&amp;lt; close window;
		// Create the flavor table and update it to
		// the original table
		dt2 = New Table( "combined",
			New Column( "Cup Color", character, set values( colorList ) ),
			New Column( "Flavors", character, set values( flavorList ) )
		);
		dt &amp;lt;&amp;lt; Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
		close( dt2, nosave );
	)
);
// Set the String Col Edit Box action
scb &amp;lt;&amp;lt; Set Function( Function( {this, which}, flavorList[which] = scb &amp;lt;&amp;lt; get( which ) ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Mar 2018 17:30:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52825#M29918</guid>
      <dc:creator>BeefSupreme</dc:creator>
      <dc:date>2018-03-08T17:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search for unique values in column and use in input window?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52840#M29925</link>
      <description>&lt;P&gt;Using a Modal window is a very unique type of window.&amp;nbsp; There are several rules that you must follow.&amp;nbsp; One of which involves a Button Box with the text of "OK".&amp;nbsp; It has a special function in a modal window.&amp;nbsp; So you can use them, but you will need to study up on them, and do some practicing with them.&lt;/P&gt;
&lt;P&gt;My preference is not to use Modal windows, but rather use Functions() or Expr() elements to encapsulate the code, keeping it from being executed until the script indicates it should be run.&amp;nbsp; Below is a simple example of how to do that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );

// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i &amp;lt;= N Items( colorList ), i++,
	Insert Into( flavorList, "" )
);

// Create the display window
nw = New Window( "Select Flavors",
	//&amp;lt;&amp;lt; Modal,
	Text Box( "Enter in Flavors for each Color" ),
	tb = Table Box(
		String Col Box( "Colors", colorList ),
		scb = String Col Edit Box( "Flavors", flavorList )
	),
	Button Box( "OK",
		nw &amp;lt;&amp;lt; close window;
		// Create the flavor table and update it to
		// the original table
		dt2 = New Table( "combined",
			New Column( "Cup Color", character, set values( colorList ) ),
			New Column( "Flavors", character, set values( flavorList ) )
		);
		dt &amp;lt;&amp;lt; Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
		close( dt2, nosave );
		runAdditionalCodePlease;
	)
);
// Set the String Col Edit Box action
scb &amp;lt;&amp;lt; Set Function( Function( {this, which}, flavorList[which] = scb &amp;lt;&amp;lt; get( which ) ) );

runAdditionalCodePlease = Expr(
	Dialog("This represents the kind of things that",
		"you may want to run after the data entry.",
		"By placing the code inside an Expr() or in",
		"a Function().  The code will be run only",
		"when executed within the code."
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Mar 2018 19:34:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-search-for-unique-values-in-column-and-use-in-input/m-p/52840#M29925</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-03-08T19:34:18Z</dc:date>
    </item>
  </channel>
</rss>

