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
WendyLou315
Level III

How to use Number Edit Box new value

Hello everyone!  I feel like such a novice today.  I cannot seem to find clear information on how to have Number Edit Box values update a Window, other Number Edit Boxes, and equations when values are changed.  My biggest issue is that I have over 30 Number Edit Boxes that feed 2 equations/formulas.  Setting the starting values, I have down.  If a value is changed, everything else needs to update and I can't figure out what I'm missing and online research has led me no further than when I started. 

I have created a small, simple script in hopes of someone here can help me get this understanding through my thick skull.

 

Thank you all in advance for your knowledge and patience!

doTheMath = function({ val1, val2},
	{result},
	( val1 * val2 ) 
);

var1 = 0;
var2 = 0;

nw = new window( " Testing ",
	<< modal,
	testingVLB = V List Box(
		enterValues = H List Box(
			tbBox1 = Text Box( " Enter Value 1" ),
			nebBox1 = Number Edit Box(var1),
			tbBox2 = Text Box( " Enter Value 2" ),
			nebBox2 = Number Edit Box(var2),
			var1 = nebBox1 << get,
			var2 = nebBox2 << get,
			),
		testResult = doTheMath( var1 , var2),
		tbNothing = Text Box(""),
		if(all(var1!=0, var2!=0), tbResult = Text Box( " Your Result is: " || char( var1 ) || "x" || char( var2 )|| "=" || char( testResult ) ))
	);
);
1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: How to use Number Edit Box new value

Try this code.  You have to use the << set function() construct for number edit boxes.

 

doTheMath = function({ val1, val2},
	{result},
	( val1 * val2 ) 
);

var1 = 0;
var2 = 0;

// Save the callback steps as an expression because they're the same for both number edit boxes
num_expr = expr(
	var1 = nebBox1 << get;
	var2 = nebBox2 << get;
	if (!isempty(var1) & !isempty(var2),
		testResult = doTheMath( var1 , var2);
		tbResult << set text(char(testresult));
	);
);


nw = new window( "Testing ", << modal,
	testingVLB = V List Box(
		enterValues = H List Box(
			tbBox1 = Text Box( " Enter Value 1" ),
			nebBox1 = Number Edit Box(var1, 10, << set function(num_expr)),
			tbBox2 = Text Box( " Enter Value 2" ),
			nebBox2 = Number Edit Box(var2, 10, << set function(num_expr)
			),
		),
		tbresult = text box(""),
	),
);

View solution in original post

4 REPLIES 4
pmroz
Super User

Re: How to use Number Edit Box new value

Try this code.  You have to use the << set function() construct for number edit boxes.

 

doTheMath = function({ val1, val2},
	{result},
	( val1 * val2 ) 
);

var1 = 0;
var2 = 0;

// Save the callback steps as an expression because they're the same for both number edit boxes
num_expr = expr(
	var1 = nebBox1 << get;
	var2 = nebBox2 << get;
	if (!isempty(var1) & !isempty(var2),
		testResult = doTheMath( var1 , var2);
		tbResult << set text(char(testresult));
	);
);


nw = new window( "Testing ", << modal,
	testingVLB = V List Box(
		enterValues = H List Box(
			tbBox1 = Text Box( " Enter Value 1" ),
			nebBox1 = Number Edit Box(var1, 10, << set function(num_expr)),
			tbBox2 = Text Box( " Enter Value 2" ),
			nebBox2 = Number Edit Box(var2, 10, << set function(num_expr)
			),
		),
		tbresult = text box(""),
	),
);

WendyLou315
Level III

Re: How to use Number Edit Box new value

FANTASTIC!  Thanks so much for getting me back on track.

Re: How to use Number Edit Box new value

You might want to research the Number Edit Col Box object if you have that many related numeric inputs.

WendyLou315
Level III

Re: How to use Number Edit Box new value

Okay, Mark.  I will do that.  Thanks so much.