Skip to main content
Previous section   Next section

Adding Class Parameters to a Class

A class parameter defines a constant value for all objects of a given class. When you create a class definition (or at any point before compilation), you can set the values for its class parameters. By default, the value of each parameter is the null string; to set a parameter's value, you must explicitly provide a value for it. At compile-time, the value of the parameter is established for all instances of a class. This value cannot be altered at runtime.

You can add a class parameter to a class definition in two ways:

  • Adding a class parameter to the class definition using the Class Editor.

  • Using the New Class Parameter wizard.

To add a method using the Class Editor, position the cursor on a blank line in the Class Editor and enter a class parameter:

Parameter P1 = "x";
Copy code to clipboard

New Class Parameter Wizard

You can use the New Class Parameter Wizard to create a new class parameter. You can open the New Class Parameter wizard using the Class > Add > Class Parameter . Alternatively, right-click the Class Inspector and select Add New Class Parameter or select the New Class Parameter icon images/gstd_newparametericon.png on the toolbar.

The New Class Parameter wizard prompts you for information. Select Finish at any time (default values are provided for any information you have not specified).

See for more information about class parameters see the chapter “Caché Classes” in Using Caché Objects.

The New Class Parameter wizard prompts you for the following information (you can later modify any of these values):

Name

(required) Name of the class parameter. This name must be a valid parameter name and must not conflict with the name of a previously defined parameter.

For a general discussion on names see the chapter “Caché Classes” in Using Caché Objects.

Description

(optional) Description of the new class parameter. This description is used when the class' documentation is displayed in the online class library documentation.

A description may include HTML formatting tags. For more details, see “Using HTML Markup in Class Documentation” in the chapter “Defining and Compiling Classes” in Using Caché Objects.

Default

Default value for the class parameter. This will be the default value for this parameter for all instances of this class.