Index-label dot syntax

New to Analytica 7.0

I . "label"

Analytica's Intelligent Arrays provide enormous flexibility in that you can modify, add or remove indexes (dimensions) and existing Definitions will generalize automatically -- in most cases. Before Analytica 7.0, there was one exception. If a.n expression refers to a particular index value, such as:

IF Tech = "Solar" THEN 200 ELSE 900

And you change "Solar" to "PV" as a value in index Tech it would break this expression. In release 7.0 and after, it will update this expression automatically, since it realizes that "Solar" is a value of Index Tech. But in some cases, where the index isn't obvious, it can't do that automatically. Now you can tell it what Index, the text is a value of by using syntax

 Tech."Solar"

or more generally

 <index> . <text literal>

This syntax consists of the identifier of an index, a dot, and a text literal (which can use single or double quotes).

Use this when your index (I) is a list-of-text index, and "label" is one of the index elements, and you express that this text literal needs to be the same as the index label.

The result of evaluating this construct is just "label". The association with the index does not impact equality -- i.e., even if two indexes, I and J are totally separate but both happen to have an element "label", I."label" = J."label" is still True.

The syntax provides two advantages:

  1. It tells Analytica that the text literal is the value in the index. If you later change the label in the index. Analytica will automatically rewrite this expression, replacing it with the new value. Hence, it helps avoid logical errors that can creep into a large model if you forget to update some expressions after changing an index label.
  2. During evaluation, it double checks that "label" is indeed an element of the index. If not, it issues an evaluation-time warning. If you ignore the warning, the value is "label".

See also

Comments


You are not allowed to post comments.