ParameterEnumeration

Revision as of 00:49, 7 January 2018 by Max (talk | contribs)


ParameterEnumeration is an attribute of a function that specifies a list of possible values for a function parameter that is displayed by Expression Assist. It has no effect impact on how a parameter is evaluated or when errors are reported -- it is used only by Expression Assist to suggest allowed values when typing a call to the function.

Enumerated parameter values

Some function parameters have a list of allowed values, which we call an enumerated list. For example, the «part» parameter of the DatePart function can be "Y" to get the year, "MMMM" to get the full name of the month, or many other options. Expression Assist shows the enumerated list when you are entering the parameter to show you the available codes, along with text explaining each one.

DatePartPartEnum.png

The Expression Assist popup shows the possible codes with a description of each. You can use the mouse or arrow keys to select a value insert into the definition that you are typing.

Specifying for a user-defined function

When writing a User-Defined Function (UDF) with one or more enumerated parameters, you can define the possible codes and descriptions using the ParameterEnumeration attribute. If you do that, Expression Assist will use them to give popup suggestions when you or others use the function.

By default, the ParameterEnumeration attribute is not visible in the Object window or Attribute panel. So, you must first make it visible, thus:

  • From the Object menu, select Attributes....
  • In the Attributes dialog, from the Class menu, select Functions.
  • Double click on the Parameter Enumeration attribute to turn on a check mark next to it.
  • Press OK
  • Open the Object Window for your UDF.

The ParameterEnumeration attribute should now be visible.

When adding content to this attribute, you must adhere carefully to this syntax:

 param1Name
   val1|description
   val2|description
     ⁞
   valM|description
 param2Name
   val1|description
   val2|description
     ⁞
   valN|description
 ⁞

Each parameter name appears as a single word on a line. You list only the enumerated parameters, but you may have more than one. You must follow each possible value by a pipe character (|), followed by an optional description. Here is an example for a single parameter named buttons used in the built-in Error function:

   buttons
   	0|OK only
   	1|OK and Cancel (default)
   	2|Abort, Retry and Ignore
   	3|Yes, No and Cancel
   	4|Yes and No
   	5|Retry and Cancel

Notes

  • After you've typed information into this attribute, it's good practice to switch its visibility off again, since it will just be a distraction to others who may browse or use your function.
  • The enumerations for built-in functions are in the Analytica.ini file, located in the Analytica install directory.
  • Once you turn on ParameterEnumeration in the Object Window, you can view the ParameterEnumeration for a given built-in function by bringing up its Object Window by selecting it from the Definition Menu.

History

Introduced in Analytica 4.5.

See Also

Comments


You are not allowed to post comments.