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


To define a custom function, use New Custom Function(). After a function is defined, you can add or activate it in the current running instance of JMP using Add Custom Functions() . Similarly, you can remove or deactivate a function using Remove Custom Functions().
New Custom Function() requires three parameters: namespace, functionName, functionDefinition. Additional messages may be passed to define the following:
funcDef = Function( {x, y = 10}, x + y );
description = "This function adds 2 values. If only 1 argument is specified, the 2nd argument defaults to 10.";
ex2 = Expr(
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
parmHint1 = "x value";
newAdd = New Custom Function( "myNamespace", "Add Ten", funcDef );
newAdd << Description( description );
newAdd << Prototype( "myNameSpace:Add Ten(x,<y=10>)" );
newAdd << Example( "myNameSpace:Add Ten(4)" );
newAdd << Example( Name Expr( ex2 ) );
newAdd << Parameter( "Number", parmHint1 );
newAdd << Parameter( "Number", parmHint2 );
newAdd << Formula Category( "NumberStuff" );
图 9.8 Custom Function in the Scripting Index
The Formula Category message results in a new category in the Formula Editor’s list of formula categories. Custom functions are shown with an underline in the Formula Editor. Also see the hint text from the Parameter messages.
图 9.9 Custom Function in the Formula Editor
To delete a custom function, use Remove Custom Functions( {"name"} ).
Remove Custom Functions( {"myNamespace:Add Ten"} );