OnChange

Revision as of 04:51, 13 February 2014 by Lchrisman (talk | contribs) (Created page with "Category:Attributes ''new to Analytica 4.6'' The OnChange attribute of a variable contains an expression that gets evaluated when the Defi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

new to Analytica 4.6

The OnChange attribute of a variable contains an expression that gets evaluated when the Definition of a variable changes.

When a variable is defined as a Choice or Checkbox, the expression is evaluated when the user changes the selection. For a Table, the expression is not evaluated when individual cells are edited, but it is evaluated when the final edit is made (e.g., when the green checkbox is pressed or edit table window is closed).

The expression can contain side-effects. For example, within the expression, you can assign to a global variable using the := operator. Such side-effects are not permitted in variable definitions. The result of the evaluation is not saved and is never used. Hence, the whole purpose of the expression is to enact some sort of side-effect.

The expression syntax is the same as the syntax for a Definition attribute.

OnChange replaces the Script attribute which was used for Choice and Checkbox controls prior to Analytica 4.6. The Script attribute is still present and still works (so that legacy models still work), but has the disadvantage that is uses Typescript, which meant that you had to learn something new. Since OnChange uses expression syntax, you don't have to learn something new. When both OnChange and Script are present, OnChange evaluates before Script. OnChange is more general than Script is/was in that it can be used with any variable, including as textbox inputs.

The OnChange expression is always evaluated in mid-mode.


See Also

Comments


You are not allowed to post comments.