<?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 Use JSL to recode a column with user input in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Use-JSL-to-recode-a-column-with-user-input/m-p/549199#M76572</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking to use JSL to recode a column (creating a new column), based on user input.&amp;nbsp; I have data that we get from a batch process, and we can identify each batch based on time, so I can clean up the data to look something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ddegennaro_0-1664198640109.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45753i9CEAED80A9EDC376/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ddegennaro_0-1664198640109.png" alt="ddegennaro_0-1664198640109.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I would like to do is then prompt the user for input, in this case the lot number that corresponds to each batch, which would then be used to recode a new column with the lot number corresponding to the batch number. The final table would look something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ddegennaro_1-1664198930345.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45754i15DABAE33079113E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ddegennaro_1-1664198930345.png" alt="ddegennaro_1-1664198930345.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;There is an additional caveat: The number of batches in a campaign is variable, anywhere from 1-16.&amp;nbsp; The goal for this script is that it can be run on the manufacturing floor after the campaign of batches is complete, so looking to make it user friendly and easy to run.&amp;nbsp; Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 15:59:02 GMT</pubDate>
    <dc:creator>ddegennaro</dc:creator>
    <dc:date>2023-06-09T15:59:02Z</dc:date>
    <item>
      <title>Use JSL to recode a column with user input</title>
      <link>https://community.jmp.com/t5/Discussions/Use-JSL-to-recode-a-column-with-user-input/m-p/549199#M76572</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking to use JSL to recode a column (creating a new column), based on user input.&amp;nbsp; I have data that we get from a batch process, and we can identify each batch based on time, so I can clean up the data to look something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ddegennaro_0-1664198640109.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45753i9CEAED80A9EDC376/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ddegennaro_0-1664198640109.png" alt="ddegennaro_0-1664198640109.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I would like to do is then prompt the user for input, in this case the lot number that corresponds to each batch, which would then be used to recode a new column with the lot number corresponding to the batch number. The final table would look something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ddegennaro_1-1664198930345.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45754i15DABAE33079113E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ddegennaro_1-1664198930345.png" alt="ddegennaro_1-1664198930345.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;There is an additional caveat: The number of batches in a campaign is variable, anywhere from 1-16.&amp;nbsp; The goal for this script is that it can be run on the manufacturing floor after the campaign of batches is complete, so looking to make it user friendly and easy to run.&amp;nbsp; Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:59:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-JSL-to-recode-a-column-with-user-input/m-p/549199#M76572</guid>
      <dc:creator>ddegennaro</dc:creator>
      <dc:date>2023-06-09T15:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Use JSL to recode a column with user input</title>
      <link>https://community.jmp.com/t5/Discussions/Use-JSL-to-recode-a-column-with-user-input/m-p/549245#M76574</link>
      <description>&lt;P&gt;This is too simple to put to manufacturing floor but should give some possible ideas how you could approach this:&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 = New Table("example",
	Add Rows(4),
	New Column("Batch", Numeric, Ordinal, Values([1,2,3,4]));
);

recode_batches = Expr(
	aa_recode = Associative Array(ncb_batch &amp;lt;&amp;lt; get, sceb_lot &amp;lt;&amp;lt; get);
	dt &amp;lt;&amp;lt; New Column("Lot Number", Character, Nominal, &amp;lt;&amp;lt; Set Each Value(
		aa_recode[:Batch];
	));
);

init_batches = Associative Array(:Batch) &amp;lt;&amp;lt; get keys;
nw = New Window("Input",
	H List Box(
		Table Box(
			ncb_batch = Number Col Box("Batch", init_batches),
			sceb_lot = String Col Edit Box("Lot Number", Repeat({""}, N Items(init_batches))),
		),
		Panel Box("Actions",
			Lineup Box(N Col(2),
				Button Box("OK",
					recode_batches;
					nw &amp;lt;&amp;lt; close window;
				),
				Button Box("Cancel", nw &amp;lt;&amp;lt; close window)
			)
		)
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Scripting Guide (&lt;A href="https://www.jmp.com/support/help/en/16.2/index.shtml#page/jmp/constructors-for-new-windows.shtml" target="_blank" rel="noopener"&gt; Scripting Guide &amp;gt; Display Trees &amp;gt; Construct Custom Windows &amp;gt; Constructors for New Windows&lt;/A&gt;&amp;nbsp;) and Scripting Index have lots of different options on how to build New Windows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are also quite a few things to consider when building something like this this. Below are few questions to think about:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Should user be asked to fill batch -&amp;gt; lot information one by one? Or all at once (like my example)?&lt;/LI&gt;
&lt;LI&gt;What type of error situations there might be?&lt;/LI&gt;
&lt;LI&gt;If logging is needed, what type?&lt;/LI&gt;
&lt;LI&gt;Should the window be modal (block usage of JMP until OK / Cancel is pressed)?&lt;/LI&gt;
&lt;LI&gt;What will be done after new column has been created?&lt;/LI&gt;
&lt;LI&gt;How will this be shared? Add-in, script in network drive?&lt;/LI&gt;
&lt;LI&gt;How this will be modified in the future?&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 26 Sep 2022 14:00:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-JSL-to-recode-a-column-with-user-input/m-p/549245#M76574</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-09-26T14:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Use JSL to recode a column with user input</title>
      <link>https://community.jmp.com/t5/Discussions/Use-JSL-to-recode-a-column-with-user-input/m-p/549268#M76576</link>
      <description>&lt;P&gt;This works wonderfully, thank you! And thank you as well for the additional things to consider.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 14:33:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Use-JSL-to-recode-a-column-with-user-input/m-p/549268#M76576</guid>
      <dc:creator>ddegennaro</dc:creator>
      <dc:date>2022-09-26T14:33:14Z</dc:date>
    </item>
  </channel>
</rss>

