cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
adel922
Level I

User Entered Values to Column values using JSL

I am new to JSL Scripting.

I am trying to populate a column using entries from a panel box.

In part of my code below, I am trying to get the value entered ,34, to populate a column named Price Code. However, when I run this code an empty column is returned.

I have tried using Get Values (Num) in place of Set Values(Num) and I still get an empty Price Code column.

 

dataTable = New Table( "Data Table",
Add Rows( 3 ),
New Column( "Customer Name",
Character,
"Nominal",
Set Values( {"Jane", "Scott", "Abby"} )
),
New Column( "Dollar Amount",
"Continuous",
Set Values( [2002, 1323, 1954] )
)
);

popUp = New Window ("Number", << modal(),
        Panel Box("Enter a Number", lineup box ( N col (1)),
            number = Number edit box (34), ),
        Panel Box ("Actions", H List Box (  Button Box ("OK", keep_going = 1;                    
                    Num = :number << Get;),
           Button Box ("Cancel", keep_going = 0)   ),   ),
);

dataTable << New Column("Price Code",Numeric, "Continuous", Set Values(Num));

 

 

17 REPLIES 17
shah47
Level II

Re: User Entered Values to Column values using JSL

Sorry I should rephrase that, there is no error message but the sample names in the data table are not being replaced with the user input

txnelson
Super User

Re: User Entered Values to Column values using JSL

Not being able to see your sample data table, I am not completly sure what the issue is, but for sure, the main issue is that you are not doing anything to write the values from the input screen to the data  table.  Below is a modification of your code that writes the values to the data table


Names Default To Here( 1 );
dt=open("$SAMPLE_DATA/big class.jmp");
dt<<new column("Sample",character);
dt << New Column("Sample Number",Character,Formula(Left(:Sample, Length(:Sample) - 1)),EvalFormula);
dt = current data table();
InputWindow = New Window( "Enter Input",
	<<modal(),
	Table Box(
		String Col Box( "Sample Number",
			{"Sample 01", "Sample 02", "Sample 03", "Sample 04", "Sample 05",
			"Sample 06"}
		),
		Col Box(
			"Sample Names",
			teb1 = Text Edit Box( "Enter Sample Name" ),
			teb2 = Text Edit Box( "Enter Sample Name" ),
			teb3 = Text Edit Box( "Enter Sample Name" ),
			teb4 = Text Edit Box( "Enter Sample Name" ),
			teb5 = Text Edit Box( "Enter Sample Name" ),
			teb6 = Text Edit Box( "Enter Sample Name" )			
		)
	),
	Button Box( "OK",
		sample name 1 = teb1 << Get Text;
		sample name 2 = teb2 << Get Text;
		sample name 3 = teb3 << Get Text;
		sample name 4 = teb4 << Get Text;
		sample name 5 = teb5 << Get Text;
		sample name 6 = teb6 << Get Text;
	)
);

Show(
	sample name 1,
	sample name 2,
	sample name 3,
	sample name 4,
	sample name 5,
	sample name 6,
);


:sample[1]=sample name 1;
:sample[2]=sample name 2;
:sample[3]=sample name 3;
:sample[4]=sample name 4;
:sample[5]=sample name 5;
:sample[6]=sample name 6;

dt = current data table();
// Sort the samples by sample name
Sample Number<<set property(value ordering, {teb1, teb2, teb3, teb4, teb5, teb6});
dt << Sort(By(Sample Number),Order(Ascending),Replace Table);
Jim
shah47
Level II

Re: User Entered Values to Column values using JSL

Thanks so much for your help, here's my full script, I still cannot get teb1, teb2,... etc to replace sample number 01, 02,...etc. In the current script, the user input just seems to replace the values of sample name and sample number in the first row, second row etc. I would like the user input to replace sample number 01, 02, 03, 04, 05, 06 etc

dt=New Table();
dt=current data table();

current data table() << Bring Window To Front;
Wait(0);
Main Menu("Paste With Column Names");

// Change the column name
Col1=column("X-Value");
Col1<<set name("Cycle");
Col2=column("Y-Value");
Col2<<set name("Response");

// Create a new column for sample names
dt << New Column("Sample Number",Character,Formula(Left(:Sample, Length(:Sample) - 1)),EvalFormula);
dt = current data table();

Names Default To Here( 1 );

InputWindow = New Window( "Enter Input",
	<<modal(),
	Table Box(
		String Col Box( "Sample Number",
			{"Sample Number 01", "Sample Number 02", "Sample Number 03", "Sample Number 04", "Sample Number 05",
			"Sample Number 06"}
		),
		Col Box(
			"Sample Number",
			teb1 = Text Edit Box( "Enter Sample Name" ),
			teb2 = Text Edit Box( "Enter Sample Name" ),
			teb3 = Text Edit Box( "Enter Sample Name" ),
			teb4 = Text Edit Box( "Enter Sample Name" ),
			teb5 = Text Edit Box( "Enter Sample Name" ),
			teb6 = Text Edit Box( "Enter Sample Name" )			
		)
	),
	Button Box( "OK",
		Sample Number 1 = teb1 << Get Text;
		Sample Number 2 = teb2 << Get Text;
		Sample Number 3 = teb3 << Get Text;
		Sample Number 4 = teb4 << Get Text;
		Sample Number 5 = teb5 << Get Text;
		Sample Number 6 = teb6 << Get Text;
	)
);

Show(
	Sample Number 1,
	Sample Number 2,
	Sample Number 3,
	Sample Number 4,
	Sample Number 5,
	Sample Number 6,
);


:sample number[1]=Sample Number 1;
:sample number[2]=Sample Number 2;
:sample number[3]=Sample Number 3;
:sample number[4]=Sample Number 4;
:sample number[5]=Sample Number 5;
:sample number[6]=Sample Number 6;


// Sort the samples by sample name
Sample Number<<set property(value ordering, {"Running Buffer","Std 01","Std 02","Std 03","Std 04","Std 05","Ctrl",teb1,teb2,teb3,teb4,teb5,teb6,
"07","08","09","10","11","12","13","14","15","16","17","18","19","20"});
dt << Sort(By(Sample Number),Order(Ascending),Replace Table);

// Exclude and delete any Startup Buffers and Startup Reference Samples; Cycle 1-9
dt << Select Where( Cycle <= 9);
dt << Exclude;
dt << Delete Rows;

win = New Window( "Graph", text = TextEditBox("Change Me"), text << Set Font( "Arial Black" ), text << Font Color( black ), text << Enable( 1 );

dt << Select Where( Sample Number != "Running Buffer");
dt << Exclude;
dt << Hide;
summarize(Bline=mean(:Response)); 
dt << Clear Row States;
dt << New Column("Blank Subtracted Response",Numeric,Formula((Response-Bline)),EvalFormula);

// Bivariated plot. 

biv = Bivariate(Y( :Blank Subtracted Response ), X( :Cycle ) );
Report( biv )[Frame Box(1)] << Row Legend( Sample Number, color(1), marker(1), Marker Theme( "Solid" ));

dt << Select Where( Sample Number != "Std 03");
dt << Exclude;
dt << Hide;

Current Data Table(dt);
dt << Clear Row States;

// Normalize the data
dt << New Column("Normalized Response",Numeric,Formula(Blank Subtracted Response/Predicted Blank Subtracted Response*100),EvalFormula);

biv = Bivariate(Y( :Normalized Response ), X( :Cycle ) );
Report( biv )[Frame Box(1)] << Row Legend( Sample Number, color(1), marker(1), Marker Theme( "Solid" ));

// Create table of reportable results
Oneway(
	Y( :Normalized Response  ),
	X( :Sample Number ),
	Means and Std Dev( 1 ),
	Mean Lines( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 ),
	Points Spread( 1 ),
	Grand Mean( 0 ));
shah47
Level II

Re: User Entered Values to Column values using JSL

Just to update, the I got the values in the table to be replaced with the user input by actually specifying the row but the script seems to end there. It does not "Sort the samples by name"
txnelson
Super User

Re: User Entered Values to Column values using JSL

You are not scoping the reference properly. You reference the column Sample Number as:
:Sample Number
Please take the time to read the Scripting Guide to round out your knowledge of the components of JSL.
Help==>Books==>Scripting Guide
Jim
pmroz
Super User

Re: User Entered Values to Column values using JSL

Slightly different approach to fix your original script

Names Default To Here( 1 );

dt = current data table();
dt << New Column("Sample Number",Character,Formula(Left(:Sample, Length(:Sample) - 1)),EvalFormula);

InputWindow = New Window( "Enter Input",
	<<modal(),
	Table Box(
		String Col Box( "Sample Number",
			{"Sample 01", "Sample 02", "Sample 03", "Sample 04", "Sample 05",
			"Sample 06"}
		),
		Col Box(
			"Sample Names",
			teb1 = Text Edit Box( "Enter Sample Name" ),
			teb2 = Text Edit Box( "Enter Sample Name" ),
			teb3 = Text Edit Box( "Enter Sample Name" ),
			teb4 = Text Edit Box( "Enter Sample Name" ),
			teb5 = Text Edit Box( "Enter Sample Name" ),
			teb6 = Text Edit Box( "Enter Sample Name" )			
		)
	),
	Button Box( "OK",
		s1 = teb1 << Get Text;
		s2 = teb2 << Get Text;
		s3 = teb3 << Get Text;
		s4 = teb4 << Get Text;
		s5 = teb5 << Get Text;
		s6 = teb6 << Get Text;
		sample_list = eval list({s1, s2, s3, s4, s5, s6});
	)
);

Show(sample_list);

// Sort the samples by sample name
dt:Sample Number<<set property(value ordering, sample_list);
dt << Sort(By(:Sample Number), Order(Ascending), Replace Table);
shah47
Level II

Re: User Entered Values to Column values using JSL

Thanks all, I was wondering if I wanted to subsitutute a string in a column named sample, why won't the following script work?

 

myCol = dt  << Column ("sample");

substitute into(myCol, "01a", s1);
shah47
Level II

Re: User Entered Values to Column values using JSL

I was able to solve my problem wtih the following

 

Try( :Sample[dt << get rows where( :Sample== "01a" )] = s1 );