Skip to main content

Syntax of Parameters in Class Definitions

Describes the structure of a parameter definition. See Parameter Definitions for links to general information on defining parameters.

Introduction

A parameter definition defines a constant value available to 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, but you can specify a non-null value as part of the parameter definition. At compile-time, the value of the parameter is established for all instances of a class. With rare exceptions, this value cannot be altered at runtime.

Details

A parameter definition has the following structure:

/// description 
Parameter name As parameter_type [ keyword_list ] = value ;

Where:

  • description (optional) is intended for display in the Class Reference. The description is blank by default. See Creating Class Documentation.

  • name (required) is the name of the parameter. This must be a valid class member name, and must not conflict with any other class member names.

  • parameter_type (optional) specifies the user interface type of the parameter and is used by Studio to provide input validation for the parameter within the Inspector.

    This is not a class name; see the next section. In most cases, the compiler ignores this keyword.

    If you omit parameter_type, also omit the word As

  • value (optional) specifies the value of the parameter. If you omit value, also omit the equals sign =

  • keyword_list (optional) is a comma-separated list of keywords that further define the parameter.

    See Parameter Syntax and Keywords for a complete keyword list.

    If this list is omitted, also omit the square brackets.

Allowed Types for Parameters

The parameter_type option can be one of the following values:

  • BOOLEAN — A true (1) or false (0) value.

  • CLASSNAME — A valid class name.

  • COSCODE — ObjectScript code.

  • COSEXPRESSION — A valid ObjectScript expression.

    If a parameter is of type COSEXPRESSION, the expression is evaluated at runtime.

    Unlike most other values of the parameter Type keyword, this value affects the compiler.

  • COSIDENTIFIER — A valid ObjectScript identifier.

  • INTEGER — An integer value.

  • SQL — An SQL statement.

  • SQLIDENTIFIER — A valid SQL identifier.

  • STRING — A string value.

  • TEXT — A multi-line text value.

  • CONFIGVALUE — A parameter that can be modified outside of the class definition. Unlike most other values of the parameter Type keyword, this value affects the compiler. If a parameter is of type CONFIGVALUE, then you can modify the parameter via the $SYSTEM.OBJ.UpdateConfigParam(). For example, the following changes the value of the parameter MYPARM (in the class MyApp.MyClass so that its new value is 42:

    set sc=$system.OBJ.UpdateConfigParam("MyApp.MyClass","MYPARM",42)
    

    Note that $SYSTEM.OBJ.UpdateConfigParam() affects the generated class descriptor as used by any new processes, but does not affect the class definition. If you recompile the class, InterSystems IRIS regenerates the class descriptor, which will now use the value of this parameter as contained in the class definition (thus overwriting the change made via $SYSTEM.OBJ.UpdateConfigParam()).

You also can omit parameter_type, in which case the Inspector will allow any value for the parameter.

Example

/// This is the name of our web service.
Parameter SERVICENAME = "SOAPDemo" ;

See Also

FeedbackOpens in a new tab