GetEvaluationContext
GetEvaluationContext(index, position)
Returns information about what slice of the currently evaluating expression will be used by the final result. You would not typically use this function in your models; however, it can provide a peek into Analytica's internal state of evaluation. This has application for internal QA testing within Lumina, or it may help you to debug something in that it might help you to understand how evaluation is occurring.
The evaluation context information is used by certain internal speed-up optimizations, allowing Analytica to deduce when certain calculations can be skipped to save time, since the computed value will end up being ignored.
The evaluation context most commonly comes into being when array-abstraction automatically iterates over a index. Slice or Subscript operations may also augment the evaluation context.
When called with no parameters, GetEvaluationContext() returns a list of handles to indexes. For each of these indexes, only one slice of the currently evaluating expression will be retained in the final result.
When a handle to an «index» is provided as the first parameter, it returns the index value indicating which slice along that index will be retained by the final result. When the index is not in the evaluation context, it returns Null. When you pass position: True
, the position along the indicated index is returned.
Examples
This expression returns the full evaluation context:
MetaIndex index := GetEvaluationContext() Do GetEvaluationContext(index)
Function ShowEvalCxt() :=
MsgBox(MetaIndex index := GetEvaluationContext() Do GetEvaluationContext(index))
Index Division := ['Sales', 'Marketing', 'Engineering', 'Manufacturing', 'Accounting']
Variable Budget := Table(Division)(350K, 80K, 140K, 250K, 40K)
Function RelBudget(x: atom)
Definition: ShowEvalCxt(); x/Sum(budget,Division)
Variable PctBudget := RelBudget(Budget)
When PctBudget
is evaluated, you'll see a MsgBox appear 5 times, once for each division, Each time, Division
is the only index, and the evaluation context reveals which division is being calculated.
History
This function was introduced in Analytica 4.6.
Enable comment auto-refresher