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.";
// examples can be multiple statements inside expr()
ex2 = Expr(
	dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
	myNameSpace:Add Ten( :age[4], 20 );
);
parmHint1 = "x value";
parmHint2 = "<y=10>";
 
// create function using variables
// the commands can also be accepted as arguments in New Custom Function
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)" );
// expr() Examples need to be passed inside NameExpr()
newAdd << Example( Name Expr( ex2 ) );
newAdd << Parameter( "Number", parmHint1 );
newAdd << Parameter( "Number", parmHint2 );
newAdd << Formula Category( "NumberStuff" );
 
// add myNamespace:Add Ten function to system
Add Custom Functions( newAdd );
Figure 8.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.
Figure 8.9 Custom Function in the Formula Editor
To delete a custom function, use Remove Custom Functions( {"name"} ).
Remove Custom Functions( {"myNamespace:Add Ten"} );

Help created on 7/12/2018