## Solution

Use 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.

Payment table built in a Table Box
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,
<<setformat( 13, "Currency", cur ), // JMP 14 sets the formatM
<<Set Function( // a callback function for responding when the
Function( {this}, // entry fields change
borrow = this << get; // get the current value
freshen(); // run the common code
)
)
),
Text Box( " amount" ) // label the entry field, space it over a bit
),
H List Box( // ditto
Number Edit Box(
years,
<<setformat( 13, "Best" ),
<<Set Function(
Function( {this},
years = this << get;
freshen();
)
)
),
Text Box( " years" )
),
H List Box( // ditto
Number Edit Box(
apr,
<<setformat( 13, "Best" ),
<<Set Function(
Function( {this},
apr = this << get;
freshen();
)
)
),
Text Box( " apr" )
)
),
Border Box( Left( 100 ), Text Box( "Interesting", <<setfontsize( 40 ) ) ) // label
)
),
Spacer Box( size( 10, 10 ), color( "dark green" ), <<setAutoStretching( 1, 0 ), <<setMaxSize( 1e5, 10 ) ),
tb = Table Box( // here's the table box. You could put columns here, but
// the freshen function will do that in a second, using "tb".
<<setShadeAlternateRows( 1 ), // set the table properties to make a green-bar report
<<setShadeHeadings( 0 ),
<<setHeadingColumnBorders( 0 ),
<<setUnderlineHeadings( 1 ),
<<setColumnBorders( 0 ),
<<setRowBorders( 0 ),
<<setShadeCells( 0 )
)
),
<<backgroundcolor( RGB Color( 245, 255, 245 ) ) // pale green
)
);
freshen = Function( {},
{// local variables
rate = (apr / 100) / 12, day = Min( 28, Day( Today() ) ), month = Month( Today() ), year = Year( Today() ), dates = J( 1 + years * 12, 1, 0 ), i,
payment = Payment( rate, 12 * years, borrow ), interest = -Interest Payment( rate, 0 :: 12 * years, 12 * years, borrow ), principal =
-Principal Payment( rate, 0 :: 12 * years, 12 * years, borrow ), payment2 = interest + principal, balance =
Present Value( rate, 12 * years :: 0, payment, 0 ), CumulativeInterest = Cumulative Sum( interest )},
For( i = 1, i <= N Rows( dates ), i++,
If( month > 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, <<setformat( 11, "yyyy-mm-dd" ) ) );
tb << append( Number Col Box( "Payment to Principal", principal, <<setformat( 13, "Currency", cur ) ) );
tb << append( Number Col Box( "Payment to Interest", interest, <<setformat( 13, "Currency", cur ) ) );
tb << append( Number Col Box( "Cumulative Interest", CumulativeInterest, <<setformat( 13, "Currency", cur ) ) );
tb << append( Number Col Box( "Monthly Payment", payment2, <<setformat( 13, "Currency", cur ) ) );
tb << append( Number Col Box( "Outstanding Balance", balance, <<setformat( 13, "Currency", cur ) ) );
0;// return nothing
);
freshen();