Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming

> ## Defining an object reference as a variable

> This is the syntax to define an object reference as a variable:

> Syntax
>     DEFINE [ access-mode ] VARIABLE object-reference
>            AS [ CLASS ] type-name .

> Element descriptions for this syntax diagram follow:

> ``object-reference``

> The name of a variable that will contain an object reference.

> ``access-mode``

> The optional access modifier (`PRIVATE`|`PROTECTED`|`PUBLIC`) if the variable is being defined as a data member in a class definition. In a procedure, the `access-mode` cannot be specified and is always private.

> `CLASS`

> The `CLASS` keyword is required if `type-name` conflicts with an abbreviation for a built in Progress data type, such as `INT` (`INTEGER`). Otherwise, it can optionally be used to clarify the readability of the statement.

> ``type-name``

> The type name of the class or interface. For more information on type names, see the "Using the CLASS construct" section or the "Using the INTERFACE construct" section, respectively.

> The following example shows a fragment of the `Main` class from the sample classes that are fully implemented in the "Sample classes" section. This fragment shows several object references defined as variables:

>     CLASS Main:
>         DEFINE PRIVATE VARIABLE rCustObj
>             AS CLASS acme.myObjs.CustObj NO-UNDO.
>         DEFINE PRIVATE VARIABLE rCustObj2
>             AS CLASS acme.myObjs.CustObj NO-UNDO.
>         DEFINE PRIVATE VARIABLE rCommonObj
>             AS CLASS acme.myObjs.Common.CommonObj NO-UNDO.
>         DEFINE PRIVATE VARIABLE rIBusObj
>             AS CLASS acme.myObjs.Interfaces.IBusObj NO-UNDO.
>         DEFINE PRIVATE VARIABLE rHelperClass
>             AS CLASS acme.myObjs.Common.HelperClass NO-UNDO.
>         CONSTRUCTOR PUBLIC Main( ):
>             /* Create an instance of the HelperClass class */
>             rHelperClass = NEW acme.myObjs.Common.HelperClass( ).
>             /* Create an instance of the CustObj class */
>             rCustObj = NEW acme.myObjs.CustObj( ).
>         END CONSTRUCTOR.
>         ...
>         DESTRUCTOR PUBLIC Main( ):
>             DELETE OBJECT rCustObj.
>             rCustObj = ?.
>             DELETE OBJECT rHelperClass.
>             rHelperClass = ?.
>         END DESTRUCTOR.
>     END CLASS.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095