How to: |
After a class definition exists, you can declare objects of that class. This is identical to declaring simple variables of a built-in data type. You can declare objects using the Class Editor, or by coding the declaration directly in the Procedure Editor.
Prerequisite: When declaring an object (that is, a class instance), the procedure in which you are declaring it must already include or import the class definition.
To declare an object using the Variable Editor:
or
Click the New variable button on the Application toolbar.
This adds the class to the list of data types in the Type combo box in the New Variable dialog box, making it available to you when you create additional objects in the future.
Note that local declarations must immediately follow the function CASE command, preceding all the other commands in the function.
You can declare a local or global object in the Procedure Editor using the DECLARE command. To make the declaration:
You can also create global objects using the COMPUTE command. For information about the COMPUTE command, see COMPUTE.
To declare an object in the Procedure Editor using the DECLARE command, use this syntax
DECLARE [(] objectname/class; . . . [)]
where:
Is the name of the object that you are creating. The name is subject to the standard naming rules of the Maintain Data language.
Is the name of the class of which this object will be an instance.
Groups a sequence of declarations into a single DECLARE command. The parentheses are required for groups of local declarations. Otherwise, they are optional.