The ISA function determines whether a variable is of a certain type, class, or structure name. It can also test whether a variable is a valid object or pointer, whether it is an array or scalar, and if a variable is associated with a file.
Result = ISA(Variable [, Typename] [, /ARRAY ] [, /FILE ] [, /NULL] [, /NUMBER] [, /SCALAR ] )
Returns 1 (TRUE) if Variable is defined, and (optionally) matches Typename or one of the other keywords. Otherwise, 0 (FALSE) is returned.
Note: If Variable is a scalar object or pointer, and Typename is not present, ISA returns 1 (TRUE) if the object or pointer is valid, and 0 (FALSE) if it is a null object or pointer.
An IDL variable or expression.
An optional scalar string type name to test against. Typename can be an IDL basic type name (like “FLOAT”), an object class name, or a structure name. For objects, the value 1 (TRUE) is returned if the variable contains Typename as either the class name or the name of a superclass. For structures, the value 1 is returned if the variable is a named structure of Typename, or if the variable inherits from a structure of Typename. For structures, the type name “Anonymous” may also be used to determine if the variable is an anonymous structure. In all cases, name matching is case insensitive.
Note: If Variable is a scalar object or a one-element object array, then Typename can be the class name or the name of a superclass. If Variable is an object array with two or more elements, Typename can only be the IDL basic type name “OBJECT”. Structure arrays do not have this restriction because every element in a structure array must be of the same structure type.
Note: If Variable is an undefined variable, and Typename is set to "UNDEFINED", then ISA will return 1 (TRUE). This is the only case where ISA will return 1 for an undefined variable.
Note: If Variable is equal to !NULL, and Typename is set to "UNDEFINED", then ISA will return 1 (TRUE). The NULL keyword can be used to distinguish between undefined variables and !NULL variables.
Set this keyword to return 1 (TRUE) if Variable is an array, list, or structure and (optionally) matches Typename, and 0 (FALSE) otherwise. This keyword cannot be combined with the SCALAR keyword.
Set this keyword to return 1 (TRUE) if Variable is associated with a file (using the ASSOC function) and (optionally) matches Typename, and 0 (FALSE) otherwise.
Set this keyword to return 1 (TRUE) if Variable is equal to the !NULL system variable, and 0 (FALSE) if otherwise. This keyword cannot be combined with any other keywords.
Tip: The NULL keyword allows you to distinguish between a variable that is simply undefined, and a variable that is equal to !NULL.
Set this keyword to return 1 (TRUE) if Variable is a numeric type, and 0 (FALSE) if otherwise. Numeric types include byte, any signed or unsigned integer type, float, double, complex, or double complex.
Set this keyword to return 1 (TRUE) if Variable is a scalar and (optionally) matches Typename, and 0 (FALSE) otherwise. This keyword cannot be combined with the ARRAY keyword.
; undefined variable foo
Statement |
IDL Prints |
PRINT, ISA(foo) |
0 |
a = 1.0
Statement |
IDL Prints |
PRINT, ISA(a) |
1 |
PRINT, ISA(a, /NUMBER) |
1 |
PRINT, ISA(a, 'Float') |
1 |
PRINT, ISA(a, /SCALAR) |
1 |
PRINT, ISA(a, /SCALAR, /NUMBER) |
1 |
PRINT, ISA(a, 'Float', /SCALAR) |
1 |
PRINT, ISA(a, 'Float', /ARRAY) |
0 |
PRINT, ISA(a, 'String') |
0 |
PRINT, ISA(STRING(a), /NUMBER) |
0 |
list = LIST(1,2,3)
Statement |
IDL Prints |
PRINT, ISA(list, 'LIST') |
1 |
PRINT, ISA(list, /ARRAY) |
1 |
struct = {MYSTRUCT, field1: 'hi'}
Statement |
IDL Prints |
PRINT, ISA(struct) |
1 |
PRINT, ISA(struct, 'MYSTRUCT') |
1 |
; structures are always arrays PRINT, ISA(struct, /ARRAY) |
1 |
ptr = PTR_NEW()
Statement |
IDL Prints |
PRINT, ISA(ptr) |
0 |
PRINT, ISA(ptr, /SCALAR) |
0 |
PRINT, ISA(ptr, /ARRAY) |
0 |
PRINT, ISA(ptr, ‘POINTER’) |
1 |
obj = OBJ_NEW('IDLgrModel')
Statement |
IDL Prints |
PRINT, ISA(obj, /SCALAR) |
1 |
; IDL basic type PRINT, ISA(obj, 'OBJREF') |
1 |
; my class PRINT, ISA(obj, 'IDLgrModel') |
1 |
; a superclass PRINT, ISA(obj, 'IDLitComponent') |
1 |
; not a superclass PRINT, ISA(obj, 'IDLgrView') |
0 |
8.0 |
Introduced |
8.1 | Added NUMBER keyword |
8.2 | Added NULL keyword |
ASSOC , SIZE , TYPENAME, IDL Data Types