Caché ObjectScript Reference
$PARAMETER
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   
Search:    

Returns the value of the specified class parameter.
Synopsis
$PARAMETER(class,parameter)
Parameters
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 parameter 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:
  ZNSPACE "Samples"
  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
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