Verifies that the class instance to which the specified object reference points is an instance of the specified object type, inherits from the specified super class, or implements the specified interface. If the object reference is valid and points to an instance of the specified type, the function returns TRUE. Otherwise, it returns FALSE.

Syntax

TYPE-OF ( object-reference , object-type-name ).
object-reference

An object reference to a class instance.

object-type-name

Specifies the type name of a class, a super class, or an interface that might be defined, inherited from, or implemented (respectively) by the object referenced by object-reference. If object-type-name specifies an interface that is inherited by an interface that the class instance implements, then the inherited interface is also implemented by the class instance specified by the object-type-name. Specify the object type name using the syntax described in the Type-name syntax reference entry. With an appropriate USING statement, you can also specify an unqualified class or interface name alone.

Notes

  • If using generics, you cannot use a type parameter by itself in the generic class implementation where a type would be specified for the TYPE-OF() and CAST() built-in functions. For example:

    CLASS MyGeneric<T AS Animal>: 
      METHOD VOID makeNoise(myPLO AS Progress.Lang.Object):      
        IF TYPE-OF(myPLO, T) //compiler error: T is a type parameter
        THEN
          CAST(myPLO, T):Sound(). //compiler error
      END METHOD.
    END CLASS. 

    In such cases, you can use the constraint type, instead of T. For example:

    CLASS MyGeneric <T AS Animal>: 
      METHOD VOID makeNoise(myPLO AS Progress.Lang.Object): 
          IF TYPE-OF(myPLO, Animal) THEN
             CAST(myPLO, Animal):Sound().
      END METHOD. 
    END CLASS.

See also

Type-name syntax, USING statement