ISA

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.

Note: The ISA function only looks at the high-level properties of a variable such as the data type or dimensions. It does not examine individual elements within a variable. You can use the IDL_Variable class for more data-specific methods.

Syntax

Result = ISA(VariableTypename, /ARRAY, /BOOLEAN, /COMPLEX, /FILE, /FLOAT, /INTEGER, /NULL, /NUMBER, /SCALAR, /STRING, /UNSIGNED)

Return Value

Returns true (1) if Variable is defined, and (optionally) matches Typename or one of the other keywords. Otherwise, false (0) 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.

Argument

Variable

An IDL variable or expression.

Typename

An optional scalar string type name to test against. The following table contains the list of typenames which will return true (1) for a given variable type:

Variable Type Allowed Typenames
Undefined or !NULL (0) Undefined (use /NULL to distinguish)
Byte (1)

Byte, IDL_Byte, IDL_Integer, IDL_Number, IDL_Variable

Int (2)

Int, IDL_Int, IDL_Integer, IDL_Number, IDL_Variable

Long (3)

Long, IDL_Long, IDL_Integer, IDL_Number, IDL_Variable

Float (4)

Float, IDL_Float, IDL_Number, IDL_Variable

Double (5)

Double, IDL_Double, IDL_Number, IDL_Variable

Complex (6)

Complex, IDL_Complex, IDL_Number, IDL_Variable

String (7)

String, IDL_String, IDL_Variable

Structure (8) STRUCT, structure name, or "Anonymous"
Double Complex (9)

Dcomplex, IDL_Dcomplex, IDL_Number, IDL_Variable

Pointer (10)

Pointer, IDL_Pointer, IDL_Variable

Objref (11) Objref, class name, or superclass name
Uint (12)

Uint, IDL_Uint, IDL_Integer, IDL_Number, IDL_Variable

Ulong (13)

Ulong, IDL_Ulong, IDL_Integer, IDL_Number, IDL_Variable

Long64 (14)

Long64, IDL_Long64, IDL_Integer, IDL_Number, IDL_Variable

Ulong64 (15)

Ulong64, IDL_Ulong64, IDL_Integer, IDL_Number, IDL_Variable

Note: All of the above strings are 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 "OBJREF".

Keywords

ARRAY

Set this keyword to return 1 (true) if Variable is an array, list, or structure and (optionally) matches Typename, and 0 (false) otherwise. You can combine this keyword with BOOLEAN, COMPLEX, FILE, FLOAT, INTEGER, NUMBER, and STRING. This keyword cannot be used with the SCALAR keyword.

BOOLEAN

Set this keyword to return 1 (true) if Variable is a BOOLEAN variable (a variable of type byte with the boolean flag). You can combine this keyword with ARRAY, FILE, NUMBER, or SCALAR. This keyword cannot be used with the FLOAT, INTEGER, or STRING keywords.

COMPLEX

Set this keyword to return 1 (true) if Variable is type COMPLEX or DCOMPLEX, or 0 (false) otherwise. You can combine this keyword with ARRAY, FILE, or SCALAR. This keyword cannot be used with the BOOLEAN, FLOAT, INTEGER, or STRING keywords.

FILE

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.

FLOAT

Set this keyword to return 1 (true) if Variable is type FLOAT or DOUBLE, or 0 (false) otherwise. You can combine this keyword with ARRAY, FILE, or SCALAR. This keyword cannot be used with the BOOLEAN, COMPLEX, INTEGER, or STRING keywords.

INTEGER

Set this keyword to return 1 (true) if Variable is one of the integer data types (including BYTE), or 0 (false) otherwise. You can combine this keyword with ARRAY, FILE, or SCALAR. This keyword cannot be used with the BOOLEAN, COMPLEX, FLOAT, or STRING keywords.

NULL

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 used with any other keywords.

Tip: The NULL keyword allows you to distinguish between a variable that is undefined, and a variable that is equal to !NULL.

NUMBER

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. You can combine this keyword with ARRAY, FILE, or SCALAR.

SCALAR

Set this keyword to return 1 (true) if Variable is a scalar and (optionally) matches Typename, and 0 (false) otherwise. You can combine this keyword with BOOLEAN, COMPLEX, FILE, FLOAT, INTEGER, NUMBER, and STRING. This keyword cannot be used with the ARRAY keyword.

STRING

Set this keyword to return 1 (true) if Variable is type STRING, or 0 (false) otherwise. You can combine this keyword with ARRAY, FILE, or SCALAR. This keyword cannot be used with the BOOLEAN, COMPLEX, FLOAT, INTEGER, or NUMBER keywords.

UNSIGNED

Set this keyword to return 1 (true) if Variable is an unsigned integer type (byte, uint, ulong, ulong64), or 0 (false) otherwise. You can combine this keyword with ARRAY, FILE, or SCALAR. This keyword cannot be used with the BOOLEAN, COMPLEX, FLOAT, or STRING keywords.

Examples

; undefined variable foo

PRINT, ISA(foo) ; IDL prints 0

 

a = 1.0d

PRINT, ISA(a)           ; 1

PRINT, ISA(a, /NUMBER)  ; 1

PRINT, ISA(a, /FLOAT)   ; 1

PRINT, ISA(a, 'Float')  ; 0

PRINT, ISA(a, /SCALAR)  ; 1

PRINT, ISA(a, /SCALAR, /FLOAT)  ; 1

PRINT, ISA(a, 'IDL_Number')  ; 1

PRINT, ISA(a, 'IDL_Variable')  ; 1

 

a = "hello"

PRINT, ISA(a, /STRING)  ; 1

PRINT, ISA(a, /STRING, /SCALAR)  ; 1

PRINT, ISA(a, /STRING, /ARRAY)   ; 0

 

list = LIST(1,2,3)

PRINT, ISA(list, 'LIST')  ; 1

PRINT, ISA(list, /ARRAY)  ; 1

 

struct = {MYSTRUCT, field1: 'hi'}

PRINT, ISA(struct)              ; 1

PRINT, ISA(struct, 'MYSTRUCT')  ; 1

; structures are always arrays

PRINT, ISA(struct, /ARRAY)      ; 1

 

ptr = PTR_NEW()

PRINT, ISA(ptr)            ; 0

PRINT, ISA(ptr, "POINTER") ; 1

 

obj = OBJ_NEW('IDLgrModel')

; 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

Version History

8.0

Introduced

8.1 Added NUMBER keyword
8.2 Added NULL keyword

8.4

Added BOOLEAN, COMPLEX, FLOAT, INTEGER, STRING keywords

8.5 Added support for IDL_Variable and its subclasses
8.9 Added UNSIGNED keyword

See Also

ASSOC, SIZE, TYPENAMEIDL Data Types