Other inquiry operators (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. 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).
Inquiry Functions That Identify Object Types shows functions that identify object types.
Is Associative Array(x) |
|
Is Directory(x) |
|
Is Empty(global) Is Empty(dt) Is Empty(col) |
|
Is Expr(x) |
|
Is File(x) |
|
Is List(x) |
|
Is Matrix(x) |
|
Is Name(x) |
|
Is Namespace(x) |
|
Is Number(x) |
|
Is Scriptable(x) |
|
Is String(x) |
|
Type(x) |