BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted
Mickyboy
Community Trekker

Stuck on Modal

Hello All,

i was hoping that someone can help me with Modal, previously i was calculating FV in my JMP script as follows:

Finalivc2 << New Column( "Runs", Numeric, Continuous );
:Runs<<set each value(2);
Finalivc2 << New Column( "Replicates per Run", Numeric, Continuous);
:Replicates per run<<set each value(1);
Finalivc2 << New Column( "Format Variability %GCV", Numeric, Continuous, Formula( ((2^root(((:IR)/(:Runs)+(:Residual)/(:Replicates per Run*:Runs)),2))-1)*100 ), Format( "fixed dec", 4, 1 ) );

which worked OK, although on ocassions i would forget to update the :Runs and :Replicates per run parameters which gave me some grief, i decided to automate this process using modal as follows

FV_param = New Window ("Format Variability Parameters", << Modal, << Return Result,
			Text Box ("Select Format Variability Parameters"),//Create the display box
			HListBox(
				LineupBox (NCol (2), 
					Text Box ("Runs NOT REPLICATES"), Runs = numberEditBox(2),
					Text Box ("Replicates NOT RUNS"), Replicates per Run = numberEditBox(1),
					), // end of lineupbox
				LineupBox ( NCol (1), ButtonBox ("OK"), ButtonBox ("Cancel"))
			) // end HListBox
);

show (FV_param, FV_param ["Runs"], FV_param ["Replicates per Run"], 
		FV_param ["Button"] );

If (FV_param ["Button"] == -1,
	Caption (" Wait...Aborting..."); Wait (3) ; Caption(Remove); Throw());
StatusMsg ("Processing next steps");
RemoveFrom (FV_param, NItems(FV_param)); // Removes the last item "Button 1" from the assignment list
Eval List(FV_param); // the assignment from the display box

Eval( 
	Substitute(
			Expr( Finalivc2 = New Column( "Runs", Numeric, "Continuous", Format( "Best", 12 ),
			Expr( Finalivc2 = New Column( "Replicates per Run", Numeric, "Continuous", Format( "Best", 12 ),  
				) 
			), 
		Expr( __FV_param__ ), Runs, Replicates per Run
	) 
)));

Finalivc2 << New Column( "Format Variability %GCV", Numeric, Continuous, Formula( ((2^root(((:IR)/(:Runs)+(:Residual)/(:Replicates per Run*:Runs)),2))-1)*100 ), Format( "fixed dec", 4, 1 ) );

i have no doubt i am doing the evaluating and substituting incorrectly, i am not getting the variables runs and Relicates per run in the table, and its then not doing the calculation, can anyone please offer some help

 

Thanks

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Staff (Retired)

Re: Stuck on Modal

I'm not sure where the journal is coming from or why it would say that. I run your code, with a dt open, and I get this:

Capture.PNGcolumns added with values set

I think @pmroz  answer is not returning the values through the <<ReturnResult but rather through global variables. Your JSL is using the EvalList(FV_Param) to move the returned answers to the same global variables.

 

Is your table being created with the columns and values now? Maybe there is another issue after that.

Craige
0 Kudos
9 REPLIES 9
Craige_Hales
Staff (Retired)

Re: Stuck on Modal

the last bit of your script should look something like this. You may also run into some naming issues with JSL variable names and column names that are the same; using dt:Runs or global:Runs may help get the right one.

dt=currentDataTable(); // you should already have a variable for your data table

dt<<New Column( "Replicates per Run", Numeric, "Continuous", Format( "Best", 12 ), <<setEachValue( Replicates per Run ) );
						
dt<<New Column( "Runs", Numeric, "Continuous", Format( "Best", 12 ), <<setEachValue( Runs ) );						

dt<<New Column( "Format Variability %GCV",
	Numeric,
	Continuous,
	Formula( ((2 ^ Root( ((:IR) / (:Runs) + (:Residual) / (:Replicates per Run * :Runs)), 2 )) - 1) * 100 ),
	Format( "fixed dec", 4, 1 )
);

Craige
0 Kudos
Mickyboy
Community Trekker

Re: Stuck on Modal

Hi Craige,

 

have run out of time today but will try this in the morning and let you know, the problem i was having was evalusting and substituting the values from the dialogue boxes to the equation.

 

thanks

0 Kudos
Mickyboy
Community Trekker

Re: Stuck on Modal

Hi Craige,

 

Had some time so tried to run the script with your suggestion, still didnt run, get the same error in debug, not enough arguments in access of evaluation of sustitute.

 

Regards

Mickyboy

0 Kudos
Craige_Hales
Staff (Retired)

Re: Stuck on Modal

(What version of JMP are you running? I'm on 14...)

 

You don't need to use substitute(...). Try replacing your eval( ... substitute(... (expr(... code with something like

 

 

dt<<New Column( "Runs", Numeric, "Continuous", Format( "Best", 12 ), <<setEachValue( Runs ) );

 

In your example, the parenthesis nesting has left substitute(eval(...)) with a single argument to substitute. Substitute needs (edit two->three) three arguments. 

 

Craige
Mickyboy
Community Trekker

Re: Stuck on Modal

Hi Craige,

l am running the same version 14, so now my code looks like this

FV_param = New Window ("Format Variability Parameters", << Modal, << Return Result,
			Text Box ("Select Format Variability Parameters"),//Create the display box
			HListBox(
				LineupBox (NCol (2), 
					Text Box ("Runs NOT REPLICATES"), Runs = numberEditBox(2),
					Text Box ("Replicates NOT RUNS"), Replicates per Run = numberEditBox(1),
					), // end of lineupbox
				LineupBox ( NCol (1), ButtonBox ("OK"), ButtonBox ("Cancel"))
			) // end HListBox
);

show (FV_param, FV_param ["Runs"], FV_param ["Replicates per Run"], 
		FV_param ["Button"] );

If (FV_param ["Button"] == -1,
	Caption (" Wait...Aborting..."); Wait (3) ; Caption(Remove); Throw());
StatusMsg ("Processing next steps");
RemoveFrom (FV_param, NItems(FV_param)); // Removes the last item "Button 1" from the assignment list
Eval List(FV_param); // the assignment from the display box

dt<<New Column( "Runs", Numeric, "Continuous", Format( "Best", 12 ), <<setEachValue( Runs ) );
dt<<New Column ( "Replicates per Run", Numeric, "Continuous", Format( "Best", 12 ), <<setEachValue( Replicates per Run ) );

but it still wont set the valuse to what was input into the modal boxes, i get this in the Journal:


Format Variability %GCV
.
.
.
.
.
.
.
.
.

No values are posted in the Journals.

Any ideas??

 

Thanks for your help

 

0 Kudos
pmroz
Super User

Re: Stuck on Modal

You are trying to use the number edit box variables as values that were entered.  You can't do that; instead you need to extract the values from the number edit boxes using << get.  In the code below I've appended _neb to the variables:

FV_param = New Window( "Format Variability Parameters",
	<<Modal,
	<<Return Result,
	Text Box( "Select Format Variability Parameters" ), //Create the display box
	H List Box(
		Lineup Box( N Col( 2 ),
			Text Box( "Runs NOT REPLICATES" ),
			Runs_neb = Number Edit Box( 2 ),
			Text Box( "Replicates NOT RUNS" ),
			Replicates per Run_neb = Number Edit Box( 1 ),

		), // end of lineupbox
		Lineup Box( N Col( 1 ), 
			Button Box( "OK", 
				runs = runs_neb << get;
				replicates per run = replicates per run_neb << get;
			), 
			Button Box( "Cancel" ) )
	) // end HListBox
);
0 Kudos
Craige_Hales
Staff (Retired)

Re: Stuck on Modal

I'm not sure where the journal is coming from or why it would say that. I run your code, with a dt open, and I get this:

Capture.PNGcolumns added with values set

I think @pmroz  answer is not returning the values through the <<ReturnResult but rather through global variables. Your JSL is using the EvalList(FV_Param) to move the returned answers to the same global variables.

 

Is your table being created with the columns and values now? Maybe there is another issue after that.

Craige
0 Kudos
Mickyboy
Community Trekker

Re: Stuck on Modal

Hi Graige,

Your solution from yesterday was correct, i miss coded, i used 

dt<< new column instead of finalivc2<<new column and now it works perfectly

RunsReplicates per RunFormat Variability %GCV
2126.1
2125.9
2129
2128.4
2129
2129.6
2128.4
2128.4
2120.7

 

My sincere apologies, it works great, thanks very much for your patience and help, it is greatly appreciated.

Sincere Regards

Mickyboy

 

Mickyboy
Community Trekker

Re: Stuck on Modal

Hi pmroz,

 

Thanks very much for your reply, i accepted Craige post from yesteday as the solution, i had miss coded from yesterday.

 

Regards,

Mickyboy.

 

 

0 Kudos