# System variables

## System variables in Analytica

System variables are variables predefined in Analytica. They control many kinds of behavior and appearance. You can modify most of them via dialog windows such as the Preferences dialog. For example, the system variable SampleSize controls the number of random samples used to represent uncertain quantities in Monte Carlo simulation. You can view and modify it the Uncertainty Sample tab in Uncertainty Setup dialog.

You can use System variables in expressions. For example, you could define a function to estimate the standard error in the estimate of the mean of x of a Monte Carlos sample as:

Function Error_in_mean(x) := Sdeviation(x)/Sqrt(SampleSize)

Two important system variables are built-in Indexes:

• Run is the Index over random samples, defined as Sequence(1, SampleSize)
• Time is the standard index for Dynamic simulation.

There are a few useful system variables that you can't modify via a standard dialog (unlike SampleSize, for example). We list those below. You can change these directly by assigning to them in the Onclick attribute of Button or Onchange attribute user input variable. You can also view and modify them via the Typescript window. Press Ctrl-' (Control key and single quote) to open this Window.

Altogether, there are more than 160 system variables. Some of the system variables are described below, you can see others at Category: System Variables. You can see the full list by typing list sysvar in the Typescript window. Some are esoteric or obsolete and only exist for compatibility with legacy models.

## System Literals

An internal distinction has been implemented between system literals and more general system variables. For backward compatibility, they all still appear as class "Sysvar" to users, but the treatment internally is quite different.

System literals contain a single literal value, usually either a long, real, or tex, but it can also be a general Analytica Value. They are designed for fast access by internal code, so they can be treated almost as if they were global C++ variables. They do not have the definition / mid-value / prob-value / index-value distinction that general Analytica variables have. There is just one value, and that value serves as the definition, mid-value, prob-value, or if a tuple, the index-value. There is never any evaluation. Literals are typed -- an integer literal must contain an integer, tex literal a tex, etc. Most Analytica system variables are literals.

In typescript, a Tex literal is not quoted when it is set. For example, the Tex-literal graph_AxisTitleFont could be set using the typescript command:

Graph_AxisTitleFont: Arial,14,1

If quotes were included, they would become part of the literal value. The typescript command is setting the value of the system literal -- there is no definition to set. The definition is essentially "virtual", having the same contents as the value. For a non-Tex-literal, you would normally include the quotes because the typescript command would be setting the definition -- after the definition is evaluated, the value would not contain the quote characters.

General System Variables are just like ordinary Analytica variables -- they contain definitions, which get parsed and evaluated in either mid- or prob-mode. Examples are Time, Run, SampleWeight.

## Meta-Attributes of System Variables

Various system variables are treated in different ways. Previously, these flags were hard-coded and/or set internally within the Analytica codebase. Most of these properties have now been exposed in the form of system attributes.

The following attributes control the behavior of system variables (because they are intended for internal use, and because we want to minimize the chances of using up a name from the namespace that users might actually use in their model, they are prefixed with "Sys_"):

### Att_dirties

Applies to a system literal. When this attribute is false, then changing the value of the system variable does not cause the model / linked module to become marked as "dirty".

When the model and no linked module is marked as dirty, the File → Save option is grayed out, and Analytica will exit without asking the user whether he wishes to save his changes.

### Att_Savealways

When true, the system variable is saved with the model even if its value has not changed from its default value.

## Default Values

When a model is stored, Analytica determines whether a system variable and/or its attributes should be stored with the model, usually by detecting whether its value differs from the system default value. When a model is closed, or a New model started, Analytica resets all system variables to their original (default) values. This process was rather limited and hacked in previous versions. The mechanism that was used internally to do this has been re-worked, and now interplays with the Analytica.ini initialization file more gracefully.

After Analytica has loaded the Analytica.ini file, it makes a copy of all system variable values, and all system variable attribute values. When it comes time to determine whether a system variable or system variable attribute value, has changed, it compares the current value to this copy. Also, when a model is closed, the copy is used to reset all system variable values. A consequence of this scheme is that the values that are defined in Analytica.ini now are treated as actual defaults. This means the true defaults don't have to be compiled into Analytica. It also means that Analytica can handle attribute values on system variables now, which the previous scheme did not deal with.

## System Variable Reference

### System Indexes

#### DensityIndex

Index containing the value ["X","Y"] used to index the result returned from the PDF and CDF functions.

### Control of Evaluation

#### SampleWeighting

Specifies the weight assigned to each sample along the Run index. See Statistical Functions and Importance Weighting.

#### IsSampleEvalMode

This is a system constant with a Mid value of 0 and a Sample value of 1, i.e.:

Mid(IsSampleEvalMode) → 0
Sample(IsSampleEvalMode) → 1

Its use is to detect whether the current evaluation mode is Mid or Sample. When creating distribution functions, occassionally the logic may differ in two cases, and in such a case, you can use and If-Then-Else on this system variable:

If IsSampleEvalMode then <<logic to generate a sample>>
Else <<logic to compute the median>>

### System Information

#### AnalyticaEdition

String containing the edition of Analytica, such as "Enterprise" or "Professional". Possible values are:

• "Enterprise with Optimizer"
• "Enterprise"
• "Professional"
• "Lite"
• "Player"
• "Power Player"

(to do: fill in and verify)

#### AnalyticaPlatform

Has the value "Windows". (On the Mac-version, returns "Mac")

#### AnalyticaVersion

An integer containing the major, minor and sub-minor version numbers. For release build 4.1.2, the value is 40102.

### UI-related

#### Sys_AnimateWindows

When set to 1, Analytica will animate windows as they open and close. This is useful for presentations since it gives a visual cue whenever a module is opened to a window. This feature is deactivated by default (Sys_AnimateWindows = 0) because some graphics processors fail to redraw properly when it is activated. If your system does not exhibit this problem, you may find it preferable.

#### AutosaveMode

• 0 = Autosave is off.
• 1 = Incremental autosave is on.

#### AutoSaveFilename

The filename of the current incremental autosave file used for crash recovery; it shows the file path Analytica is currently using to save the recovery file. The variable gets set when the file is opened, so if the model is not yet dirtied, it might still be empty (""), even if AutosaveMode=1.

You can't modify this system variable directly. Referencing it in the typescript window is a convenient way to locate the last saved recovery file.

#### AutoSaveInterval

Note used in Analytica 4.0. Analytica 4.0 does incremental autosaves only. However, the autosave system was architected to allow a future enhancement that would periodically perform a full save at a given time interval.

When set to true, a small red triangle ("flag") appears on any node containing a non-empty description or help field.

#### TableType

Controls how array values are formatted when printed in typescript, or in a MsgBox. This variable is often used by ADE users, particularly prior to ADE 4.0 (ADE 4.0 adds much more control to formatting of results in CATables, making this less important).

In Analytica 3.1 and before, there were 5 possible values (1 through 5), corresponding to 5 rather different formats.

In Analytica 4.0, the value is more general. The different aspects of printing can be controlled separately by specifying particular bits in the value. If the TABLETYPE_USE_BITS bit is set, then the other bits control the format, as follows:

 TABLETYPE_DEFN_STYLE = 1,	// Use Table(I,J,K)(...) syntax
TABLETYPE_WITH_QUOTES = 2,	// Quote Texs
TABLETYPE_FULL_PRECISION = 4,	// If set, 15 sig digits used.  If not set, numberWidth is used.
TABLETYPE_USE_BITS = 8,	// Use these individual settings, rather than the legacy hard-coded settings.
TABLETYPE_BRACKETS = 16,	// Rows have brackets & commas (for non DEFN style)
TABLETYPE_SHOW_ROW_NAME = 32,	// Row index name appears by itself on a line prior to the body
TABLETYPE_INDENT_BODY = 64,
TABLETYPE_INDENT_LEVEL = 128,
TABLETYPE_TABS = 256,
TABLETYPE_2D = 512
TABLETYPE_NO_TILDE_CONTINUATIONS = 1024,
TABLETYPE_WITH_INNER_QUOTES


If the TABLETYPE_USE_BITS flag is not set, then the value should be in the range of 1-6, corresponding to the pre-defined formats, which have the following equivalent values:

 kTTYTable=0:     TABLETYPE_USE_BITS | TABLETYPE_BRACKETS | TABLETYPE_SHOW_ROW_NAME | TABLETYPE_INDENT_LEVEL
kDemosTable=1:   TABLETYPE_USE_BITS | TABLETYPE_DEFN_STYLE | TABLETYPE_BRACKETS
kGenericTable=2: TABLETYPE_USE_BITS | TABLETYPE_SHOW_ROW_NAME | TABLETYPE_TABS
k2DGenericTable=3: TABLETYPE_USE_BITS | TABLETYPE_TABS | TABLETYPE_2D
k2DXYChartTable=4: TABLETYPE_USE_BITS | TABLETYPE_INDENT_BODY | TABLETYPE_TABS | TABLETYPE_2D
kEPSTable=5:     TABLETYPE_USE_BITS | TABLETYPE_DEFN_STYLE | TABLETYPE_WITH_QUOTES | TABLETYPE_FULL_PRECISION
kOldEPSTable=6:  TABLETYPE_USE_BITS | TABLETYPE_DEFN_STYLE | TABLETYPE_WITH_QUOTES


In Analytica/ADE 3.1, kEPSTable had the functionality that kOldEPSTable has now. (The change to kEPSTable was requested by Enrich, who added kEPSTable in the first place).

### Tables

#### Sys_TableCellDefault

This variable sets the default value for table cells when no value has been set the Cell Default attribute. In other words, Sys_TableCellDefault is the default to the default. For new models, the value of Sys_TableCellDefault is 0. If you change it, the new value will be saved with the model. To designate empty text for the default, do not type anything after the colon in the typescript command. ( Sys_TableCellDefault: )

Regardless of Sys_TableCellDefault, you can always use the Cell Default attribute to establish a default value for an individual table. First activate the Cell Default attribute by selecting Attributes... from the Object window. Place a check box next to Cell Default. The attribute will now appear in the object window for tables.

#### Sys_WarnUndefCell

This Boolean variable enables a warning when you try to evaluate a table with one or more undefined cells. For new models, this value is set to 1 (warning enabled). If you edit this variable, the new value will be saved with the model. See also Sys_WarnUndefCell.

### Dates

#### Sv__DateOriginOffset

This setting is accessible in the UI by selecting Preferences from the Edit menu. If Use Excel date origin is unchecked, it will use Jan 1, 1904 as used on Macintosh, corresponding to an offset of zero. If Use Excel date origin is checked, it will use Jan 1, 1900 as used on Excel on Windows. This corresponds to a date offset of -1462.

#### Sys_DbDatesAsText

This affects how the DBQuery() function handles date values. If dates are imported numerically, they will be processed as dates in Analytica functions. But if this creates problems, set Sys_DbDatesAsText = 1 to suppress date intelligence and handle the imported values as text. See also Sys_DbDatesAsText.

### Fonts

#### AttributeFontSize and TableFontSize

AttributeFontSize sets the font size in the attribute pane and object windows. TableFontSize sets the font size in Tables. You can toggle them both between 10 point and 13 point (small and large) in Large text in attributes & tables in the Preferences dialog from the Edit menu. Since they are preference values, they applies to all models on your Analytica installation rather than being saved to a particular model. If you want a font size other than 10 or 13, or want different sizes for AttributeFontSize and TableFontSize, you may reset them by assigning values to them individually in the Typescript window.

#### Sys_ShowFontsOnPopup

This is active (1) by default. When you select Set Node Style... from the Diagram menu, then select Font, you will see the font names displayed in the actual font styles. If this feature is taking up too much processing time or memory, set this variable to 0.

### Other

#### InternalSDKErrTries

The Frontline optimization engines sometimes fail to compute, and return an SDK error. This is a known issue that Frontline has ameliorated but not fully resolved (as of Analytica 4.5). The occurrence of these errors is not predictable. When one occurs, it is possible that the next optimization with run with no problems. This system variable determines the number of consecutive errors and automatic restarts Analytica will allow without faulting. If you are getting frequent SDK errors with InternalSDKErrTries = 0, try setting it to 5 or so. The value of this variable sticks to an individual model. The default value for new models is 0.

#### It

When you are using typescript for calculations by entering Analytica expressions, It refers to the last result. For example:

 > pi*2 returns 6.28

and after that

 > It * 2 returns 12.57

#### Sys_AllNullTreatment

This is useful for legacy models made with Analytica versions before 4.4. 4.4 changed the way Analytica handles Null values is some functions. See What's new in Analytica 4.4?.

#### WarnOnNonIndexedOp

This Boolean variable enables a warning when you omit the index attribute from array reducing functions. Sum() is an example of an array reducing function. It normally has two attributes: The array and the index to operate over. For example: Sum(cost_table, item_index). Analytica will always warn when the array has two or more dimensions and you omit the second parameter. But there is no ambiguity you are operating on a one-dimensional array or an index. In this case, Analytica will either warn or not depending on the value of WarnOnNotIndexedOp. It is always a good idea to include the index parameter regardless of the dimensions of the array. This way you can add new dimensions to the existing model without introducing ambiguities. Although WarnOnNonIndexedOp is not enabled for new models, it is a good idea to enable it if you want to enforce this guideline.