For the latest version of JMP Help, visit JMP.com/help.

Classes enable you to create objects based on templates. You can use JSL to create a definition of a class. A class definition is a template, which contains definitions for member variables, methods, and functions. After you have defined a class in JSL, you can instantiate an object that has all of the characteristics defined in the class definition.
Use the JSL function Define Class() to create a JSL class definition. Use the JSL function New Object() to instantiate an instance of a JSL class.
The JSL function Define Class() has a number of arguments that define the contents of the class:
Define Class( "class name",
	<Base Class( "base class name", <"base class name", ...> ),>
	<Show( All( Boolean ) ) | Show( <Members( Boolean ),> <Methods( Boolean ),> <Functions( Boolean )> ),>
	<Assignment Statements>
);
"class name" is the name of the class being defined.
"base class name" is one or more class names that make the set of base classes that are used as the foundation of the class being created.
Show defines the value that appears when a class object is written out using the Show(), Print(), or Write() functions. Options include:
All( Boolean ) shows all members, methods, and functions defined in a class object instance. The default value for All is true. If you specify the All option, that setting overrides any other arguments in the Show option.
Members( Boolean ) shows all member variables contained in a class object instance.
Methods( Boolean ) shows all methods contained in a class object instance.
Functions( Boolean ) shows all functions contained in a class object instance.
Note: You can specify either the All option or any number of the Members, Methods, and Functions options, but you cannot specify both options at the same time.
Note: If a class contains a _show_ method, that method overrides the Show option.
Assignment Statements are zero or more of the following assignment statements, separated by semicolons:
Defines the output of the Show(), Print(), and Write() JSL functions when an instance of the class is used as the argument.
Defines the output of the Char() JSL function when an instance of the class is used as the argument.
Notes: 
Define Class( "Pet",
	name = ""; breed = ""; color = "";
	_init_ = Method( { name, breed, color },
		this:name = name;
		this:color = color;
		this:breed = breed;
	);
	_show_ = Method( {},
		Return( name || " is a " || color || " " || breed || "." )
	);
	Get Pet Name = Method( {}, Return( name ) )
);
To instantiate an instance of a JSL class object, use New Object() JSL function with any of the following functions and arguments:
New Object( "Class Name"( constructor arguments ) );
New Object( Class Name( constructor arguments ) );
New Object( Class Reference( constructor arguments ) );
New Object( "Class Name", { constructor arguments } );
New Object( Class Name, { constructor arguments } );
New Object( Class Reference, { constructor arguments } );
class = "Pet";
xa = New Object( Pet( "Oliver", "Schnauzer", "Black" ) );
xb = New Object( class, { "Flynn", "Cockapoo", "Brown" } );
xc = New Object( class( "Mandi", "King Charles Cavalier", "Ruby" ) );
xd = New Object( "Pet"( "Charlie", "Asian", "White" ) );
xd1 = New Object( xd( "Fred", "Siamese", "Silver" ) );
xd2 = New Object( xd, { "Sam", "German Shepard", "Black and White" } );
 
Show( xa );
Show( xb );
Show( xc );
Show( xd );
Show( xd1 );
Show( xd2 );
xd2 = xd;                 // creates a second reference to xd
xdclone = xd << Clone;    // copies xd to a new instance, named xdclone
xd2:name = "Jerry";
Show( xd:Get Pet Name(), xd2:Get Pet Name(), xdclone:Get Pet Name() );
This example creates multiple instances of the "Pet" class. The output of the Show() JSL function is determined by the _show_ method that is defined in the "Pet" class definition. This example also illustrates the difference between creating a second JSL reference to a class instance and cloning a class instance. When using the Clone message, you are creating a new class instance that is independent of the original. However, the new instance starts out as a copy of the original.

Help created on 3/19/2020