$PARAMETER (ObjectScript)
Synopsis
$PARAMETER(class,parameter)
Arguments
Argument | Description |
---|---|
class | Optional — Either a class name or an object reference (OREF) to a class instance. If omitted, uses the object reference of the current class instance. When omitted, you must specify the placeholder comma. |
parameter | The name of a parameter. An expression which evaluates to a string. The value of the string must match the name of an existing parameter of the class identified by class. |
Description
$PARAMETER returns the value of a specified class parameter. $PARAMETER can look up this parameter in the current class context or in a specified class context. You can specify a class name as a quoted string, specify an OREF, or omit the class argument and take as default the current instance (see $THIS). Specifying class is optional; specifying the comma separator is mandatory.
For example:
WRITE $PARAMETER("%Library.Boolean","XSDTYPE")
There are several ways to return the value of a parameter using object syntax, as shown in the following example:
WRITE "ObjectScript function:",!
WRITE $PARAMETER("Sample.Person","EXTENTQUERYSPEC")
WRITE !,"class parameter:",!
WRITE ##class(Sample.Person).#EXTENTQUERYSPEC
WRITE !,"instance parameter:",!
SET myinst=##class(Sample.Person).%New()
WRITE myinst.%GetParameter("EXTENTQUERYSPEC")
WRITE !,"instance parameter:",!
WRITE myinst.#EXTENTQUERYSPEC
Invalid Values
-
$PARAMETER("","XMLTYPE"): attempting to invoke an invalid OREF (such as the empty string, an integer, or a fractional number) results in an <INVALID OREF> error.
-
$PARAMETER("bogus","XMLTYPE"): attempting to invoke a nonexistent class results in a <CLASS DOES NOT EXIST> error, followed by the specified class name. If a package name is not specified, InterSystems IRIS assumes the default. For example, attempting to invoke the nonexistent class “bogus” results in the error <CLASS DOES NOT EXIST> *User.bogus.
-
$PARAMETER(,"XMLTYPE"): attempting to default to the current object instance when none has been established results in a <NO CURRENT OBJECT> error.
-
$PARAMETER("%SYSTEM.Task",""): attempting to reference an invalid parameter name (for example, an empty string) or to reference a parameter by number generates an <ILLEGAL VALUE> error.
-
$PARAMETER("%SYSTEM.Task","MakeCoffee"): attempting to reference a nonexistent parameter name returns the empty string ("").
Examples
The following example specifies class names and returns the class default values for the XMLTYPE and XSDTYPE parameters:
WRITE $PARAMETER("%SYSTEM.Task","XMLTYPE"),!
WRITE $PARAMETER("%Date","XSDTYPE")
The following example specifies an OREF and returns the value of the XMLTYPE parameter for this instance:
SET oref=##class(%SYSTEM.Task).%New()
WRITE $PARAMETER(oref,"XMLTYPE")
The following example returns a system parameter using $PARAMETER syntax and using class syntax:
WRITE $PARAMETER("%SYSTEM.SQL","%RandomSig"),!
WRITE ##class(%SYSTEM.SQL).#%RandomSig
See Also
-
$CLASSMETHOD function
-
$CLASSNAME function
-
$METHOD function
-
$PROPERTY function
-
$THIS special variable