Before you can declare an object (an instance of a class), your procedure must have a class definition for that type of object. If the class:
This procedure describes how to define a new class. (If you wish to define a new subclass—that is, a class that inherits properties from another class—see How to Define a Subclass Using the Class Editor.)
or
Click the New class button on the Application toolbar.
The Member Variable dialog box opens. For instructions on how to create a variable, see How to Create a Variable in a Procedure.
The name of each member variable must be unique within the class to which it belongs; it can be identical, however, to the names of member variables of other classes.
The Member Function dialog box opens. For instructions on creating functions, see How to Create a Function.
The name of each member function must be unique within the class to which it belongs; it can be identical, however, to the names of member functions of other classes.
To define a new class (a subclass) by inheriting properties (member functions and member variables) from another class (a superclass):
or
Click the New class button on the Application toolbar.
The Member Variable dialog box opens. For instructions on creating variables, see How to Create a Variable in a Procedure.
Note that you cannot delete member variables inherited from the superclass.
Note that you cannot delete member functions inherited from the superclass; however, you can override an inherited member function it to edit or remove its source code.
The Member Function dialog box opens. For instructions on creating functions, see How to Create a Function.
The name of each member function must be unique within the class to which it belongs; it can be identical, however, to the names of member functions of other classes.
When you define a class using the Class Editor, it generates the definition in the procedure as a DESCRIBE command. If you wish to work directly with source code, you can create new class definitions and edit existing definitions directly in the Procedure Editor by using the following DESCRIBE syntax. You must issue the DESCRIBE command outside of a function—for example, at the beginning of the procedure prior to all functions.
DESCRIBE classname = ( [superclass +] memvar/type [, memvar/type] ...) [;] [memfunction [memfunction]... ENDDESCRIBE]
where:
Is the name of the class that you are defining. The name is subject to the Maintain language's standard naming rules; see the Maintain Language Reference manual for more information.
Is the name of the superclass from which you wish to derive this class. Include only if this definition is to define a subclass.
Names one of the class's member variables. The name is subject to the Maintain language's standard naming rules; see the Maintain Language Reference manual for more information.
Is a data type (a built-in format or a class).
Defines one of the class's member functions. Member functions are defined the same way as other Maintain functions, using the CASE command; see the Maintain Language Reference manual for more information.
Terminates the definition if the definition omits member functions. If it includes member functions, the semicolon is omitted and the ENDDESCRIBE command is required.
Ends the class definition if it includes member functions. If it omits member functions, the ENDDESCRIBE command must also be omitted, and the definition must be terminated with a semicolon (;).
To add a new member function or member variable:
To edit one of the class’s member functions or member variables:
For information about editing variables, see How to Edit a Variable; for information about editing functions, see How to Edit a Function. For general information about editing a class definition, see Defining Classes.
The Maintain Development Environment generates Maintain language code for classes. If you wish, you can edit this code directly in the Procedure Editor.
For more information about the DESCRIBE command, see the Maintain Language Reference manual.
or
Select the class, member variable, or member function, and press F2.
or
Click the class, member variable, or member function twice.
or
Press the Delete key.
or
Click the Delete button on the General toolbar.
The New Class and Edit Class dialog boxes enables you to create and edit classes.
The General tab has the following options:
Type the name of your class here. For information about names see the Maintain Language Reference manual.
If this class is based on another class, select that class from the list. The list comprises all of the classes that are defined in the open import module or procedure, and in any modules that have been imported into it.
The New Class and Edit Class dialog boxes enables you to create and edit classes.
The Functions tab has the following elements:
Lists the names of the class's member functions.
Opens the Member Function dialog box where you can define a new function.
Deletes a selected function from the list of functions, or if a function has been overridden, deletes the override.
Moves a selected function up in the list of functions.
Moves a selected function down in the list of functions.
Overrides the selected inherited function. You would override a function inherited from a superclass if you wish to make changes to that function in this subclass.
The New Class and Edit Class dialog boxes enables you to create and edit classes.
The Variables tab has the following elements:
Lists the class's member variables, including those that it has inherited.
Opens the Member Variable dialog box in which you can define a new variable.
Deletes a selected variable from the list of variables. You cannot delete variables that are inherited from another class definition.
Moves a selected variable up in the list of variables.
Moves a selected variable down in the list of variables.
The New Class and Edit Class dialog boxes enables you to create and edit classes.
The Descriptions tab has the following elements:
You can document the class by typing a description of it in this edit box. Maintain will turn your description into a comment in the class definition's source code in the procedure or module.
WebFOCUS |