cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
dsoltz1
Level II

Cannot perform math on returned value from Number Edit Box

I'm trying to run a very simple script that requests a numerical input from the user. Unfortunately, I cannot perform numerical operations such as subtract and divide on the returned value. Am quite new to jsl, so I must be doing something wrong that must be very simple to correct. the error message is:

 

"Cannot convert argument to a number [or matrix] in access or evaluation of 'Divide', minfeat_abs/ /*###*/1000/*###*/"

 

Any help would be greatly appreciated. Have been banging away at this for hours.

 

Please see the script below:

win = New Window( "Feature Depth" ,
<<Modal,
<<Return Result,
Text Box( "Input Min Feature Depth" ),
minfeat_abs = Number Edit Box( 4 ),
);
minfeat = -minfeat_abs/1000;
1 ACCEPTED SOLUTION

Accepted Solutions
Mauro_Gerber
Level IV

Re: Cannot perform math on returned value from Number Edit Box

Try this:

win = New Window( "Feature Depth" ,
<<Modal,
<<Return Result,
Text Box( "Input Min Feature Depth" ),
minfeat_abs = Number Edit Box( 4 ),
);

mf = win["minfeat_abs"];

mf = -mf/1000;

I think it has something to do with the <<modal mode

"I thought about our dilemma, and I came up with a solution that I honestly think works out best for one of both of us"
- GLaDOS

View solution in original post

6 REPLIES 6
Thierry_S
Super User

Re: Cannot perform math on returned value from Number Edit Box

Hi,

I did struggle with the proper way to get values out of modal windows until @txnelson showed me how:

Names Default to Here (1);

win = New Window( "Feature Depth" ,
		<<Modal,
		<<Return Result,
		Text Box( "Input Min Feature Depth" ),
		NEB = Number Edit Box(4)

);

minfeat_abs = NEB << get;
show (minfeat_abs);
minfeat = -minfeat_abs/1000;
show (minfeat);
Thierry R. Sornasse
dsoltz1
Level II

Re: Cannot perform math on returned value from Number Edit Box

Still getting an error, even when I copy and past the script that Thierry suggested.

 

deleted object reference: NEB << get in access or evaluation of 'Glue'...

 

dsoltz1_0-1616476264230.png

 

Georg
Level VII

Re: Cannot perform math on returned value from Number Edit Box

Dear all,

I think this does not work, because with closing the window, the variable and the scope has gone. JMP returns it in a different way. A global variable may work.

So when I struggle with these kind of things, I tend to look in the scripting index for the current way to do this kind of things (they may change somehow from version to version). And I find it as an example for "new window, modal", that I slightly modified, see screenshot and attached script. The reference of the window returns all you need.

 

Names Default To Here( 1 );

ex = New Window( "Dialog() example",
	<<Modal,
	<<Return Result,
	V List Box(
		H List Box( "Set this value", variable = Number Edit Box( 42 ) ),
		H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
	)
);

Show( ex );
Show( ex["variable"] );
neb_content = ex["variable"];
Show( neb_content / 2 );

Georg_0-1616483029871.png

 

Georg
dsoltz1
Level II

Re: Cannot perform math on returned value from Number Edit Box

This script performed properly by itself, but when combined with a script to select rows in a table against a given criteria (number greater than neb_content/2 for example) it gave the error: Name Unresolved: Feature{1} in access or evaluation of 'Feature' , Feature/*###*/

where "Feature" was the name of the column in the data table.

 

I would like to understand why this is occurring.

 

However, the tip on using the scripting guide with each jmp version is a good one. Thanks!

Mauro_Gerber
Level IV

Re: Cannot perform math on returned value from Number Edit Box

Try this:

win = New Window( "Feature Depth" ,
<<Modal,
<<Return Result,
Text Box( "Input Min Feature Depth" ),
minfeat_abs = Number Edit Box( 4 ),
);

mf = win["minfeat_abs"];

mf = -mf/1000;

I think it has something to do with the <<modal mode

"I thought about our dilemma, and I came up with a solution that I honestly think works out best for one of both of us"
- GLaDOS

Re: Cannot perform math on returned value from Number Edit Box

Please see Help for this topic.