该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


An example in “Manipulating Expressions” on page 248 in the “Programming Methods” chapter, showed how to use the Substitute Into() function to input coefficients for a quadratic polynomial into the quadratic formula and then use the formula to calculate the roots of the polynomial. That example required specifying the coefficients as arguments to Substitute Into().
The section Construct a Column Dialog shows an example to collect coefficients from the user using a modal dialog box.
myCoeffs = New Window( "Find the roots for the equation",
<<Modal,
H List Box(
a = Number Edit Box( 1 ),
Text Box( "*x^2 + " ),
b = Number Edit Box( 2 ),
Text Box( "*x + " ),
c = Number Edit Box( 1 ),
Text Box( " = 0" )
Button Box( "OK",
Show( a, b, c );
Button Box( "Cancel" )
x = {Expr(
(-b + Sqrt( b ^ 2 - 4 * a * c )) / (2 * a)
(-b - Sqrt( b ^ 2 - 4 * a * c )) / (2 * a)
xx = Eval Expr( x );
win = New Window( "The roots of a quadratic function",
V List Box(
Text Box( "The real roots for the equation " ),
Text Box( " " || Expr( po ) || " = 0" ),
H List Box( Text Box( "are x=" ), Text Box( xxx ) ),
Text Box( " " ), // to get a blank line
Graph Box(
Frame Size( 200, 200 ),
X Scale( xmin, xmax ),
Y Scale( ymin, ymax ),
Line Style( 2 ),
H Line( 0 ),
Line Style( 0 ),
Y Function( polynomial, x ),
Line Style( 3 ),
Pen Color( 3 ),
V Line( xx[1] ),
V Line( xx[2] ),
Marker Size( 2 ),
Marker( 0, {xx[1], 0}, {xx[2], 0} )
win = New Window( "Error",
V List Box(
Text Box( " " ),
Text Box( " Polynomial " || po || " has no real roots. " ),
Text Box( " " ),
Text Box( "Examine a graph of the function to get an idea why." ),
Graph Box(
Frame Size( 200, 200 ),
X Scale( -20, 20 ),
Y Scale( -20, 20 ),
Line Style( 2 ),
H Line( 0 ),
Line Style( 0 ),
Y Function( polynomial, x )
polynomial = Expr( a * x ^ 2 + b * x + c );
po = Char( Eval Expr( polynomial ) );
xxx = Char( Eval Expr( x ) );
If( Is Missing( xx[1] ) | Is Missing( xx[2] ), // now it’s ready for a test
图 11.31 A Custom Platform Launch Window
Clicking OK, displays a results window (图 11.32, left), with either the roots or an error message. Rerun the script, input 5, 4, and 5 respectively and click OK. Note that JMP displays an error message (图 11.32, right).
图 11.32 The Custom Platform’s Report