cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
ddegennaro
Level I

Use JSL to recode a column with user input

Hi,

 

I'm looking to use JSL to recode a column (creating a new column), based on user input.  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:

ddegennaro_0-1664198640109.png

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: 

ddegennaro_1-1664198930345.png

There is an additional caveat: The number of batches in a campaign is variable, anywhere from 1-16.  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.  Any ideas? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Use JSL to recode a column with user input

This is too simple to put to manufacturing floor but should give some possible ideas how you could approach this:

 

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 << get, sceb_lot << get);
	dt << New Column("Lot Number", Character, Nominal, << Set Each Value(
		aa_recode[:Batch];
	));
);

init_batches = Associative Array(:Batch) << 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 << close window;
				),
				Button Box("Cancel", nw << close window)
			)
		)
	)
);

Scripting Guide ( Scripting Guide > Display Trees > Construct Custom Windows > Constructors for New Windows ) and Scripting Index have lots of different options on how to build New Windows:

 

 

There are also quite a few things to consider when building something like this this. Below are few questions to think about:

  • Should user be asked to fill batch -> lot information one by one? Or all at once (like my example)?
  • What type of error situations there might be?
  • If logging is needed, what type?
  • Should the window be modal (block usage of JMP until OK / Cancel is pressed)?
  • What will be done after new column has been created?
  • How will this be shared? Add-in, script in network drive?
  • How this will be modified in the future?
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Use JSL to recode a column with user input

This is too simple to put to manufacturing floor but should give some possible ideas how you could approach this:

 

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 << get, sceb_lot << get);
	dt << New Column("Lot Number", Character, Nominal, << Set Each Value(
		aa_recode[:Batch];
	));
);

init_batches = Associative Array(:Batch) << 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 << close window;
				),
				Button Box("Cancel", nw << close window)
			)
		)
	)
);

Scripting Guide ( Scripting Guide > Display Trees > Construct Custom Windows > Constructors for New Windows ) and Scripting Index have lots of different options on how to build New Windows:

 

 

There are also quite a few things to consider when building something like this this. Below are few questions to think about:

  • Should user be asked to fill batch -> lot information one by one? Or all at once (like my example)?
  • What type of error situations there might be?
  • If logging is needed, what type?
  • Should the window be modal (block usage of JMP until OK / Cancel is pressed)?
  • What will be done after new column has been created?
  • How will this be shared? Add-in, script in network drive?
  • How this will be modified in the future?
-Jarmo
ddegennaro
Level I

Re: Use JSL to recode a column with user input

This works wonderfully, thank you! And thank you as well for the additional things to consider.