CAST( object-reference, object-type-name ).Specifies the type name of an ABL or .NET class or interface type to which the object reference is cast. This object type must be a class type in a class hierarchy that includes or implements the object-reference data type or it must be an interface type that the object-reference data type implements. 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.
A .NET generic type can be part of a cast. For example, you can cast from a System.Object to a "System.Collections.Generic.List<SHORT>", because all .NET classes, including generic classes, derive from the .NET root class. However, note that you cannot cast from a "System.Collections.Generic.List<System.Object>" to a "System.Collections.Generic.List<System.Windows.Forms.Button>". You cannot assign a "List<Button>" reference to an object reference defined as a "List<Object>", because, even though the type parameters are compatible, the two objects as a whole are not equivalent and have no inheritance relationship. Therefore, a cast between these two objects cannot work either. For more information on .NET generic types, see the Data types reference entry.
You can also use the DYNAMIC-CAST function to cast object references to object types determined at run time. This is especially useful in object-oriented applications that conform to the OpenEdge Reference Architecture (OERA). For more information on the OERA, see the Progress Software Developers Network® (PSDN): http://communities.progress.com/pcom/community/psdn.
method-name( INPUT CAST( object-reference, subclass-name ), ... ).
You can use the CAST function to cast a temp-table field, which is defined as a Progress.Lang.Object, to use as an object of another class type. For example:
DEFINE VARIABLE rCustObj AS CLASS acme.myObjs.CustObj.DEFINE TEMP-TABLE mytt FIELD CustObj AS Progress.Lang.Object.rCustObj = CAST(mytt.CustObj, acme.myObjs.CustObj).You can now use the object reference in RCustObj to invoke methods in the acme.myObjs.CustObj class.
CAST( object-reference, object-type-name ):method-name( parameters ).
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |