Identifier



Release:

4.6  •  5.0  •  5.1  •  5.2  •  5.3  •  5.4  •  6.0  •  6.1  •  6.2  •  6.3  •  6.4  •  6.5


An identifier is a unique name used to refer to a Variable, Function, or any other Class of Object or local value.

Titles and Identifiers

Each object has a Title as well as an Identifier. The Title normally appears in its node in a diagram, and in tables and graphs for variables. The Identifier is used in Definitions and other expressions.

When you create a new object, it automatically creates the identifier of the new object from the title, substituting '_' for spaces or other punctuation. It uses up to the first 48 characters.

Normally, diagrams, tables, and the Outliner show the Titles of variabes. You can switch between viewing Identifiers or Titles by pressing Ctrl+Y (or toggle Show by identifier on the Object menu). This shortcut becomes second-nature to seasoned model builders.

Features of identifiers

  • Every global object has a unique identifier, including Variables, Models, Modules, user-defined and system Functions, Attributes, and so on. Local variables in Definitions and Function parameters also have identifiers, which must be unique within that Definition.
  • Identifiers are case-insensitive. So, Profit, profit, PROFIT and prOFIt are all the same identifier.
  • An identifier normally starts with a letter, followed by zero or more letters or digits. It may include underscore '_', but not spaces or punctuation.
  • 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, a parameter identifier normally refers to the value that was passed by the caller. The exception is when the parameter has a Class Qualifier, such as (Index Object, Variable, Class, or Attribute) where the parameter refers to an object. You can use the identifier of these class parameters in the Function definition anywhere you could use the identifier of the original object.

You can't automatically tell whether an Identifier refers to a Global object or is a local variable or function parameter. So, many people use the convention of capitalizing global variables and indexes, and using lower case for local variables and function parameters.

Getting the identifier of an object

Every object has a unique identifier. You can access this underlying identifier using the expression

Identifier Of Time

returns "Time". This may seem pointless if you have to already know the identifier. But in some cases, you may use an expression to refer to the object. For example, if you pass the object as a parameter:

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 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.


These are valid (allowed) identifiers:

  • x
  • Annual_Revenue
  • Health_damage
  • Revenue_by_product_c
  • N14compliance
  • Rank17
  • A_b_c_d
  • Te1261540435

These are invalid 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, it usually automatically generates an identifier from the title. It 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, 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. For example, if you title a variable NPV, it generates its Identifier as NPV1, because NPV is the name of a built-in function. This won't be 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.


20



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.

See Also

Comments


You are not allowed to post comments.