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


Publication date: 04/21/2023

Specific Element Types

Other inquiry functions (such as Is Matrix(), Is List(), Is Scriptable(), and so on) let you test for specific types of objects. In the following example, Is Matrix() evaluates as true, then the specified calculations are run:

a = [2 3];
b = [1, 1];
c = a * b;
If( Is Matrix( c ),
	(c ^ a) / (a * b),
	Print( "c is not a matrix." )
);

[5 25]

Is Scriptable() returns 1 when the object is scriptable. Four variables in the following example refer to a data table, column, platform, and report. All four objects are scriptable, so Is Scriptable() returns 1 for each example.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = Column( "weight" );
plat = Bivariate( Y( :weight ), X( :height ) );
rep = Report( plat );
Show( Is Scriptable( dt ) );

Is Scriptable(dt) = 1;

Show( Is Scriptable( col ) );

Is Scriptable(col) = 1;

Show( Is Scriptable( plat ) );

Is Scriptable(plat) = 1;

Show( Is Scriptable( rep ) );

Is Scriptable(rep) = 1;

Is Empty() tests to see whether a variable has a value, a function, an expression, or a reference to an object. It returns 1 if the variable is undefined or holds the Empty() value.Otherwise, you get errors when referring to something that has not been created or assigned a value yet. Programmers call this an uninitialized variable.

Here is an example of a test to see whether a data table is opened and therefore assigned to the dt variable. If a data table is not opened, the Open() function prompts the user to open the table.

If( Is Empty( dt = Current Data Table() ),
	dt = Open()
);

You can use Is Empty() for any variable (such as global variable, local variable, and columns).

Table 5.6 shows functions that identify object types.

Table 5.6 Inquiry Functions That Identify Object Types

Syntax

Explanation

Is Associative Array(x)

Returns 1 if the evaluated argument is an associative array or 0 otherwise.

Is Directory(x)

Returns 1 if the x argument is a directory and 0 otherwise.

Is Empty(global)

Is Empty(dt)

Is Empty(col)

Returns 1 if the global variable, data table, or data column does not have a value (is uninitialized) or 0 otherwise.

Is Expr(x)

Returns 1 if the evaluated argument is an expression or 0 otherwise.

Is File(x)

Returns 1 if the x argument is a file and 0 otherwise.

Is List(x)

Returns 1 if the evaluated argument is a list or 0 otherwise.

Is Matrix(x)

Returns 1 if the evaluated argument is a matrix or 0 otherwise.

Is Name(x)

Returns 1 if the evaluated argument is a name or 0 otherwise. See Retrieve a Stored Expression Rather than its Result.

Is Namespace(x)

Returns 1 if the evaluated argument is a namespace or 0 otherwise.

Is Number(x)

Returns 1 if the evaluated argument is a number or missing numeric value or 0 otherwise.

Is Scriptable(x)

Returns 1 if the evaluated argument is a scriptable object or 0 otherwise.

Is String(x)

Returns 1 if the evaluated argument is a string or 0 otherwise.

Type(x)

Returns a string naming the type of x.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).