Identifier
Release: |
4.6 • 5.0 • 5.1 • 5.2 • 5.3 • 5.4 • 6.0 • 6.1 • 6.2 • 6.3 • 6.4 |
---|
An identifier is a name that is used to refer to an Analytica object or to a (temporary) value.
- Each object in Analytica's global name space has a unique identifier. This includes all nodes in your model, built-in functions, system variables, attributes, classes, typescript commands, etc.
- Inside a Function definition, the identifiers of pass-by-value parameters refer to the value that was passed by the caller.
- In an expression, a Local identifier that is declared via the Local..Do or For..Do constructs refers to the value that was computed on the right-hand side of the
:=
when the local was declared, or to values subsequently assigned to the local. - Inside a Function definition, the parameters declared with a class name (
Index
Object
,Variable
,Variable
,Class
, orAttribute
) refer to objects. The identifier of the parameter is, in general, different from the identifier of the underlying object, but the parameter identifier can be used in the Definition expression. - In an expression, local identifiers declared using LocalIndex or LocalAlias constructs name objects. In general, the identifier of the local can be different from the identifier of the underlying object.
Although some identifiers refer to objects while other identifiers refer to values, the rules for what qualifies as a legal identifier name are the same in both cases. Thus, you cannot tell from the identifier whether it names an object or a value. Many people adopt a stylistic convention of capitalizing identifiers that refer to objects, such as names of global variable and indexes, and using lower case for value identifiers.
Underlying identifier of an object
Every object has an identifier has its own identifier. You can access this underlying identifier using the expression
Identifier Of Time
returns "Time".
In some cases, the identifier you are using to refer to the object might be different from the underlying identifier. This occurs, for example, if you pass the object as a parameter. The following illustrates:
Function NameOfIndex( I : Index )
- Definition:
Identifier of I
Now call:
NameOfIndex( Time )
The result is "Time"
, not "I"
.
When an identifier names a value, you cannot access its identifier via an expression.
Local x := 4+5 Do (Identifier of X)
→ Error: 'Identifier Of x' does not exist.
Legal names for Identifiers
Identifiers are case-insensitive. Thus, Profit
, profit
, PROFIT
and prOFIt
are all the same identifier.
Identifiers must be between 1 and 20 characters in length, contain only letters A thru Z, digits 0 thru 9, and underscores, and the first character must be a letter. The capitalization of an Identifier is preserved when you enter it, so you can use "camel case" (capitalizing the first letter of each word, as in CamelCase); however, when you use an identifier in an expression, it is case insensitive. But the capitalization entered initially will be displayed whenever Analytica displays the identifier.
The following are examples of legal (allowed) identifiers:
- x
- Annual_Revenue
- Health_damage
- Revenue_by_product_c
- N14compliance
- Rank17
- A_b_c_d
- Te1261540435
The following are examples of non-legal names for identifiers:
- A&B
- n!
- 4x
- Disminución_diaria
- θ
- Απόσταση
- 升值率高于通货膨胀率
- _x --- Starting with underscore is reserved for system use
Generating an identifier from the title
When you enter a title for an object, Analytica will usually automatically generate an identifier from the title, and may ask you if you want to rename it (the exact behavior can be configured on the Preference Dialog). It does this by replacing spaces and punctuation with underscores, converting Chinese character to their Pinyin romanizations, appending digits to the end to ensure uniqueness, etc. One "gotcha" to watch out for is the appending of digits when an object already exists with the same name. So, for example, if you title a variable NPV, the automatically generated Identifier is NPV1, which isn't obvious when you are viewing only the title on a diagram. In a Definition of another variable, you will need to use NPV1 in your expression. The 1 appends here because the name NPV is already used by the built-in function.
Toggle between Title and Identifier views
In most Analytica windows, including diagrams, tables, and the outliner, you can toggle between viewing Identifiers or Titles by pressing Ctrl+Y (on toggling Show by identifier on the Object menu). This shortcut becomes second-nature to seasoned model builders.
History
The set of legal identifiers was greatly enlarged in the Analytica 6.4 release to include:
- Non-english characters
- Identifiers longer than 20 characters.
- Backquoted identifiers for arbitrary text
- Removed the generation of pinyin identifiers from Asian language titles (Chinese, Japanese, Korean), since those character sets are now allowed.
To compare the differences, use the release bar at the top of this page to 6.3 or earlier or 6.4 or later.
Enable comment auto-refresher