ProblemYou need to build a custom calculator that displays a table of numbers based on several input values.
SolutionUse Number Edit Boxes to get the values and use the Set Function method to attach JSL to the Number Edit Boxes to recalculate the table when the values are changed. Use a Table Box to hold columns of numbers. Rebuild the columns of numbers when the values change.
if( jmpversion()<"13", Open Log(1); throw("requires JMP 13 or greater")); // need default values to set up the edit boxes borrow = 1e5; years = 2; apr = 15; cur = "USD"; // "EUR" New Window( "table demo", Border Box( Left( 5 ), Right( 5 ), bottom( 5 ), // this box extends the pale green a few pixels V List Box( // border boxes need a single child, like a vlist, to hold everything Border Box( Left( 20 ), Right( 20 ), top( 10 ), bottom( 10 ), // the data entry border H List Box( // separate the data entry fields from "Interesting" title V List Box( // the three vertical entry fields and their labels H List Box( // a field and its label Number Edit Box( // a field borrow, < 12, month -= 12; year += 1; ); dates[i] = Date DMY( day, month, year ); month += 1; ); While( !Is Empty( tb << child ), (tb << child) << delete ); // remove previous data, if any // add the new columns to the table tb << append( Number Col Box( "Due Date", dates, <I'm not a finance guy. Don't assume I'm using the formulas correctly. I chose shades of green and specified some table box parameters to make the table attractive. I'm not an artist, you can do better. The green spacer box makes a nice bar of color and fills the page without making the page wider by using the AutoStretching and MaxSize options. The freshen() function is called from all three data entry fields and doesn't care which field changed. You could do something more complicated, but unless you have really slow calculations, keep it simple. You can right-click the table and make into data table to further process the data; you might want a way to save the parameters with the data table (another button, perhaps, to make the data table). You can also journal the report which will include the parameters.
See AlsoHelp->Books->Scripting Guide has more information about Table Boxes
Started scripting early 2021 and this post was really useful. I copied most of the script above and modified it for my own calculator, the output of which I am planning to use in another platform.
However, I am not fully satisfied with what I have achieved. When I open and run my script the first time, I get two pre-filled number boxes where I can enter values.

It is only when I change one of the values in the pre-filled number boxes, that the third box with the result I am actually interested in using further appears.

I think I ran into this, because what I created is based on the code provided by @Craige_Hales above.
- How can I make it, that the third box (circled in red above) appears from the beginning, but is also updated based on the input values in the other two boxes?
- Is there a more efficient solution to building a small calculator or am using an unnecessarily complicated approach?
At this point I also wanted to mention that, yes, I have been studying the Scripting Guide as well as the Scripting Index, but I am not yet a strong enough scripter to come up with my own solution. (I did not browse through "Jump into JMP Scripting" though, as I currently do not have access to my copy.)
Names default to here ( 1 );
// some default values for the first two number edit boxes
CurrentConc_wt% = 45.00;
LowestAcceptConc_wt% = 40.00;
New Window( "Calculating Concentration acceptance limit",
Border Box(Left( 5 ), Right( 5 ), bottom( 20 ),
V List Box(
Text Box("Some comment")
)
),
Border Box(Left( 5 ), Right( 5 ), bottom( 20 ),
V List Box(
Text Box("Instructions: [add instructions here later]")
)
),
Border Box(Left( 5 ), Right( 5 ), bottom( 5 ), // added this because I copied this code and left in there, just in case...
V List Box( // border boxes need a single child, like a vlist, to hold everything
Border Box(Left( 5 ), Right( 5 ), bottom( 5 ), // border for data entry boxes
H List Box(
V List Box(
Border Box(Left( 5 ), Right( 5 ), bottom( 5 ),
H List Box(
Number Edit Box(
CurrentConc_wt%,
<<SETFORMAT></SETFORMAT>
It will be a little while before I can look at this in more depth. But I think you may just be missing the call at the very end of the original JSL, freshen() , which was there to initialize all of the boxes as if something had been clicked already.
Thanks, that was an easy fix. Perhaps there's reason to be satisfied after all.