The Parameter class allows you to access the parameters in a model. More...
The PRIMER JavaScript API provides many class constants, properties and methods. For Arup to
be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase
or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you
should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your
own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:
| Name | Type | Description |
| expression (read only) | logical | true if this parameter is a *PARAMETER_EXPRESSION, false otherwise. |
| include | integer | The Include file number that the parameter is in. |
| local | logical | true if this parameter is a *PARAMETER_... _LOCAL, false otherwise. |
| model | integer | The Model number that the parameter is in. |
| mutable | logical | true if this parameter is a *PARAMETER_... _MUTABLE, false otherwise. |
| name (read only) | string | Parameter name. |
| noecho | logical | true if this parameter is a *PARAMETER_... _NOECHO, false otherwise. |
| type (read only) | constant | Can be Parameter.INTEGER, Parameter.REAL or Parameter.CHARACTER. |
| value | integer/real/string | Parameter value.
The value will be a string for parameter expressions, or a number for normal parameters. By default when a parameter value is changed PRIMER will re-evaluate and update all of the parameters in the model as changing this parameter could cause others to change because of parameter expressions. There could be some situations where changing parameters one at a time could cause problems with re-evaluation. For example, changing parameter A could temporarily cause a division by zero when re-evaluating parameter expression B until parameter C is changed. In this case the automatic re-evaluation can be prevented by using Parameter.SaveAll and Parameter.UpdateAll. |
Detailed DescriptionThe Parameter class allows to create and query parameters in a model. See the documentation below for more details. |
Constructornew Parameter(Model[Model], name[string], type[constant], expression[boolean], value[integer/real/string], suffix (optional)[constant])DescriptionCreate a new Parameter object. |
Model that parameter will be created in
Parameter name
Can be Parameter.INTEGER, Parameter.REAL or Parameter.CHARACTER.
true if *PARAMETER_EXPRESSION, false otherwise.
Parameter value. The value will be a string for character parameters or parameter expressions, or a number for integer or real parameters.
Keyword suffix Can be Parameter.LOCAL for *PARAMETER_..._LOCAL, Parameter.MUTABLE for *PARAMETER_..._MUTABLE, or Parameter.NOECHO for *PARAMETER_..._NOECHO. These may be bitwise ORed together, ie Parameter.LOCAL | Parameter.MUTABLE | Parameter.NOECHO. If omitted the parameter will not be local or mutable.
ReturnsParameter object Return typeParameter |
Details of functionsAutoReorder(Model[Model]) [static]DescriptionAuto Reorders all the parameters in the model. |
Model that contains all parameters that will be re-ordered
ReturnsNo return value |
ExampleTo auto-reorder all parameters in model m: Parameter.AutoReorder(m);
|
ClearFlag(flag[Flag])DescriptionClears a flag on the parameter. |
Flag to clear on the parameter
ReturnsNo return value |
ExampleTo clear flag f for parameter p: p.ClearFlag(f);
|
Error(message[string], details (optional)[string])DescriptionAdds an error for a parameter. For more details on checking see the Check class. |
The error message to give
An optional detailed error message
ReturnsNo return value |
ExampleTo add an error message "My custom error" for parameter p: p.Error("My custom error");
|
No arguments
Returnsnumber (real and integer parameters) or string (character parameters) Return typeNumber |
ExampleTo evaluate parameter p: var value = p.Evaluate();
|
FlagAll(Model[Model], flag[Flag]) [static]DescriptionFlags all of the parameters in the model with a defined flag. |
Model that all parameters will be flagged in
Flag to set on the parameters
ReturnsNo return value |
ExampleTo flag all of the parameters with flag f in model m: Parameter.FlagAll(m, f);
|
Flagged(flag[Flag])DescriptionChecks if the parameter is flagged or not. |
Flag to test on the parameter
Returnstrue if flagged, false if not. Return typeBoolean |
ExampleTo check if parameter p has flag f set on it: if (p.Flagged(f) ) do_something...
|
GetAll(Model[Model]) [static]DescriptionReturns an array of Parameter objects for all of the parameters in a model in Primer |
Model to get parameters from
ReturnsArray of Parameter objects Return typeArray |
ExampleTo make an array of Parameter objects for all of the parameters in model m var p = Parameter.GetAll(m);
|
GetAllOfName(Model[Model]) [static]DescriptionReturns an array of Parameter objects for all parameters in a model matching Name. If none are found that match it will return NULL. (Multiple parameters of the same name may exist if they use the _LOCAL or _MUTABLE suffices. PRIMER will also store multiple illegal instances of parameter name, using the instance as determined by the PARAMETER_DUPLICATION card.) |
Model to get parameters from
ReturnsArray of Parameter objects Return typeArray |
ExampleTo make an array of Parameter objects for all of the parameters of name in model m var p = Parameter.GetAllOfName(m, name);
|
GetFromName(Model[Model], parameter name[string]) [static]DescriptionReturns the stored Parameter object for a parameter name. WARNING: if more than one parameter Name exists (eg _LOCAL, _MUTABLE) then only the first occurrence is returned. To return all parameters matching Name use GetAllOfName() instead. |
Model to find the parameter in
name of the parameter you want the Parameter object for
ReturnsParameter object (or null if parameter does not exist). Return typeParameter |
ExampleTo get the Parameter object for parameter "THK" in model m var p = Parameter.GetFromName(m, "THK");
|
Keyword()DescriptionReturns the keyword for this parameter (*PARAMETER, *PARAMETER_EXPRESSION). Note that a carriage return is not added. See also Parameter.KeywordCards() |
No arguments
Returnsstring containing the keyword. Return typeString |
ExampleTo get the keyword for parameter p: var key = p.Keyword();
|
KeywordCards()DescriptionReturns the keyword cards for the parameter. Note that a carriage return is not added. See also Parameter.Keyword() |
No arguments
Returnsstring containing the cards. Return typeString |
ExampleTo get the cards for parameter p: var cards = p.KeywordCards();
|
SaveAll(Model[Model]) [static]DescriptionSaves the current status and values of all of the parameters in the model.
Calling this will also have the effect of turning off re-evaluating and updating of all parameters in the model
when a parameter value is changed. |
Model that the parameters will be saved in
ReturnsNo return value |
ExampleTo save the status of all of the parameters in model m: Parameter.SaveAll(m);
|
SetFlag(flag[Flag])DescriptionSets a flag on the parameter. |
Flag to set on the parameter
ReturnsNo return value |
ExampleTo set flag f for parameter p: p.SetFlag(f);
|
UnflagAll(Model[Model], flag[Flag]) [static]DescriptionUnsets a defined flag on all of the parameters in the model. |
Model that the defined flag for all parameters will be unset in
Flag to unset on the parameters
ReturnsNo return value |
ExampleTo unset the flag f on all of the parameters in model m: Parameter.UnflagAll(m, f);
|
UpdateAll(Model[Model]) [static]DescriptionUpdates all of the parameters in the model after saving the state of all parameters using
Parameter.SaveAll and modifying the parameter
values. As parameter re-evaluation has been suppressed by
Parameter.SaveAll you should ensure that all parameters
in the model can be evaluated correctly before calling this to ensure that there are no errors.
If any of the parameters cannot be evaluated then the values saved in Parameter.SaveAll
will be restored, the update will be aborted and an exception thrown.
Calling this will also have the effect of turning back on re-evaluating and updating of all parameters in the model
when a parameter value is changed. |
Model that the parameters will be updated in
ReturnsNo return value |
ExampleTo update all of the parameters in model m: Parameter.UpdateAll(m);
|
Warning(message[string], details (optional)[string])DescriptionAdds a warning for a parameter. For more details on checking see the Check class. |
The warning message to give
An optional detailed warning message
ReturnsNo return value |
ExampleTo add a warning message "My custom warning" for parameter p: p.Warning("My custom warning");
|
Xrefs()DescriptionReturns the cross references for this parameter. |
No arguments
ReturnsXrefs object. Return typeXrefs |
ExampleTo get the cross references for parameter p: var xrefs = p.Xrefs();
|
toString()DescriptionCreates a string containing the parameter data in keyword format. Note that this contains the keyword header and the keyword cards. See also Parameter.Keyword() and Parameter.KeywordCards(). |
No arguments
Returnsstring Return typeString |
ExampleTo get data for parameter p in keyword format var s = p.toString();
|