\ExpressionManager\SafeRefresh(PRefreshedVar, ParmVar[, NewValue])
PRefreshedVar { Variable that is being
refreshed.
};
ParmVar { Previous value of
variable being refreshed. };
NewValue {
Optional initial value for
expression };
If a tag parameter holds a running expression rather than a variable, care must be taken in refreshing it. The SafeRefresh method provides a convenient way for developers to ensure that all parameters are correctly refreshed, and at the same time ensures that similar operations use the same code path.
Using the Function tag as an example, its refresh module starts as follows:
Refresh [
If watch(1);
[
{***************************************************}
{
Parameters to the
Function
}
{***************************************************}
{*****
Update variables *****}
\ExpressionManager\SafeRefresh(&P1, Parm[#P1]);
\ExpressionManager\SafeRefresh(&P2, Parm[#P2]);
\ExpressionManager\SafeRefresh(&P3, Parm[#P3]);
\ExpressionManager\SafeRefresh(&P4, Parm[#P4]);
Here, the variables P1 through P4 are all parameters to the tag. SafeRefresh will instantiate the expression if necessary and will set the parameter to that expression. If the parameter is a tag reference or a simple constant, those will be handled correctly as well.