Choose Language Hide Translation Bar
Highlighted
pauldeen
Level IV

Number edit box do support << sib but do not support << prev sib

In this script, in the last two functions when the number edit box is changed I'm using that value and its left or right sibling to calculate a new value. When I change the left box I can successfully find its right (next) sibling using << sib. When I change the right box, I cannot get to its previous (left) sibling using << prev sib.

 

Number edit box do support << sib but do not support << prev sib according to my JMP 14 log. Run attached script and change the number
boxes to test for yourself.

Am I using the right function? If yes, is there a way to work around this omission?

 

dt = New Table( "untitled 1",
	Add Rows( 0 ),
	Compress File When Saved( 1 ),
	New Table Variable( "First", 1.5 ),
	New Table Variable( "Second", 2.4 ),
	New Table Variable( "Third", 0 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [] )
	)
);

LB = lineup box(NCol(4),
	Text box("Factor"),
	Text box("Total"),
	Text box("Metrology"),
	Text box("Process"),
);

TableVariables = dt << Get Table Variable Names();

New window("Variation",
	v list box(
		LB = lineup box(NCol(4),
			Text box("Factor"),
			Text box("Total"),
			Text box("Metrology"),
			Text box("Process"),
		),
		Button Box( "Write Total",ApplyTotalButton)
	)
);

for(i=1,i<=N items(TableVariables),i++,
	LB << Append(text Box(TableVariables[i]));
	LB << Append(number edit Box(num(dt<<get table variable(TableVariables[i])), << set Function(RMSEFunction)));
	LB << Append(number edit Box(0, << set Function(SMEFunction)));
	LB << Append(Text Box("0"));
);

ApplyTotalButton = Expr(
	//When the button is clicked, get the values from the left column of number edit boxes and write to the table variables.
	RMSEVals = Current Window() << xpath( "//NumberEditBox/text()" );
	For( i = 1, i <= N Items( RMSEVals ) / 2, i++,
		dt << Set Table Variable( TableVariables[i], Num( RMSEVals[(2 * i) - 1] ) )
	);
);

RMSEFunction = Function( {this},
	//When value in this Number Edit Box is changed, get the value from this box and the one to the right and add the result and put it in the text box on the far right.
	RMSE = num( this << Get text() );
	SME = num(( this << sib) << Get text() );
	(( this << sib) << sib) << set text(char(sqrt(num(RMSE)^2-num(SME)^2)));
	//Variable = (this << prev sib) << get text();
	//dt << Set Table Variable( Variable, num( this << Get text() ));
);

SMEFunction = Function( {this},
	//When value in this Number Edit Box is changed, get the value from this box and the one to the left and add the result and put it in the text box on the far right.
	RMSE = num((this << prev sib) << Get text());
	SME = num(this << Get text( this << sib()));
	( this << sib) << set text(char(sqrt(num(RMSE)^2-num(SME)^2)));
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
gzmorgan0
Super User

Re: Number edit box do support << sib but do not support << prev sib

Typically when I want to refer to a grouping  of objects, I add a container, for example, create a rowbox, then the syntax

((this << parent) << sib) << sib

would suffice.

 

However, for your example I would use a table box of  a StringColBox, two NumColEditBox, and a NumColBox. If you wanted to refer to the cell, Set Function returns two variables this and which, so it refers to the NumColEditBox and the cell.

However, by naming your boxes you can get by with a single function,

 

Names Default to Here(1);

dt = New Table( "untitled 1",
	Add Rows( 0 ),
	Compress File When Saved( 1 ),
	New Table Variable( "First", 1.5 ),
	New Table Variable( "Second", 2.4 ),
	New Table Variable( "Third", 0 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [] )
	)
);


TableVariables = dt << Get Table Variable Names();
nvar    = nitems(TableVariables);
totval  = {};
metval  = AsList(J(nvar,1,0));
procval = metval;

For(i=1, i<=nvar, i++,
	InsertInto(totval, num(dt<< get Table Variable(TableVAriables[i])))
);

TB = TableBox(
	vcol = StringColBox("Factor",TableVariables),
	tcol = NumberColEditBox("Total",totval),
	mcol = NumberColEditBox("Metrology", metval),
	pcol = NumberColBox("Process", procval)
);

vcol << set row borders(0);
pcol << set row borders(0);

New window("Variation",
	v list box(
		TB,
		Button Box( "Write Total",ApplyTotalButton)
	)
);

recalcFunction = Function( {this, which},
	//When value in this Number Edit Box is changed, get the value from this box and the one to the right and add the result and put it in the text box on the far right.
	RMSE = tcol <<get as matrix;
	SME =  mcol <<get as matrix ;
	pcol << set values ( sqrt(RMSE^2 -SME^2));
);

tcol << set Function(recalcFunction);
mcol << set Function(recalcFunction);

ApplyTotalButton = Expr(
	//When the button is clicked, get the values from the left column of number edit boxes and write to the table variables.
	RMSEVals = tcol << get;
	For( i = 1, i <= nvar, i++,
		dt << Set Table Variable( TableVariables[i],  RMSEVals[i] ) 
	);
);

  

View solution in original post

5 REPLIES 5
Highlighted
txnelson
Super User

Re: Number edit box do support << sib but do not support << prev sib

Prev Sib is not supported for Displays.  It is only available for Tree Nodes.  It would be nice if it did work for Displays.  I suggest that you enter the request into the JMP Wish List.

Jim
Highlighted
pauldeen
Level IV

Re: Number edit box do support << sib but do not support << prev sib

Any idea how to (easily) work around this?
I imagine a solution with Xpath could work and then using the locate function using this << get text to figure out which of the number edit boxes is the one that was changed. It would not be robust for repeated values though :(
The other option is to create a button that would run through all boxes and do the math, but it is an ugly solution.
Highlighted
txnelson
Super User

Re: Number edit box do support << sib but do not support << prev sib

You can get the parent for the object, and can determine the number of children for the parent, and then move to the child you need to deal with. I have not actually used this methodology, but I have played around a bit with it, and I think you could make it work.
Jim
Highlighted
pauldeen
Level IV

Re: Number edit box do support << sib but do not support << prev sib

Highlighted
gzmorgan0
Super User

Re: Number edit box do support << sib but do not support << prev sib

Typically when I want to refer to a grouping  of objects, I add a container, for example, create a rowbox, then the syntax

((this << parent) << sib) << sib

would suffice.

 

However, for your example I would use a table box of  a StringColBox, two NumColEditBox, and a NumColBox. If you wanted to refer to the cell, Set Function returns two variables this and which, so it refers to the NumColEditBox and the cell.

However, by naming your boxes you can get by with a single function,

 

Names Default to Here(1);

dt = New Table( "untitled 1",
	Add Rows( 0 ),
	Compress File When Saved( 1 ),
	New Table Variable( "First", 1.5 ),
	New Table Variable( "Second", 2.4 ),
	New Table Variable( "Third", 0 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [] )
	)
);


TableVariables = dt << Get Table Variable Names();
nvar    = nitems(TableVariables);
totval  = {};
metval  = AsList(J(nvar,1,0));
procval = metval;

For(i=1, i<=nvar, i++,
	InsertInto(totval, num(dt<< get Table Variable(TableVAriables[i])))
);

TB = TableBox(
	vcol = StringColBox("Factor",TableVariables),
	tcol = NumberColEditBox("Total",totval),
	mcol = NumberColEditBox("Metrology", metval),
	pcol = NumberColBox("Process", procval)
);

vcol << set row borders(0);
pcol << set row borders(0);

New window("Variation",
	v list box(
		TB,
		Button Box( "Write Total",ApplyTotalButton)
	)
);

recalcFunction = Function( {this, which},
	//When value in this Number Edit Box is changed, get the value from this box and the one to the right and add the result and put it in the text box on the far right.
	RMSE = tcol <<get as matrix;
	SME =  mcol <<get as matrix ;
	pcol << set values ( sqrt(RMSE^2 -SME^2));
);

tcol << set Function(recalcFunction);
mcol << set Function(recalcFunction);

ApplyTotalButton = Expr(
	//When the button is clicked, get the values from the left column of number edit boxes and write to the table variables.
	RMSEVals = tcol << get;
	For( i = 1, i <= nvar, i++,
		dt << Set Table Variable( TableVariables[i],  RMSEVals[i] ) 
	);
);

  

View solution in original post

Article Labels

    There are no labels assigned to this post.