TrackAttChanges
New in Analytica 6.5
These esoteric functions can be used to track changes that a user makes to the model, or within a part of the model. It would be extremely rare for an Analytica user to make use of these functions, they exist for internal use within Analytica. The names of these functions all begin with an underscore, which underscores how esoteric we consider them to be.
Function _TrackAttChanges( atts..., within, excludeWithin, deletionHandler )
Parameters:
- «atts»: One or more attributes to be tracked. E.g.,
_TrackAttChanges( Title, Description, Unit )
. - «within»: (Optional) Module containing all objects to track. If omitted, tracks all changes.
- «excludeWithin»: (Optional) Module to exclude from tracking (itself within «within» to be meaningful).
- «deletionHandler»: (Optional) A function you provide that gets called if an object (or objects) within tracking scope gets deleted.
Instantiates an «attTracker» which internally keeps track of which attribute values change. It tracks changes to the attributes listed in «atts» in objects that are within the module specified in «within», excluding any changes to objects within the module «excludeWithin». Both «within» and «excludeWithin» are optional (if «within» is omitted then it tracks changes to any object).
When an object is deleted, any changes logged for it are removed from its record since the object ceases to exist. To get notice of an object deletion you can supply a «deletionHandler» function, which will be called if one or more objects are deleted. The function must have the prototype signature:
Function deletionHandler( attTracker : _AttTracker atom )
It can be either a UDF or a local function. It is called after the deletion has occurred, so there is no record of which object(s) were deleted (there is no longer any way to refer to them), but it does tell you that at least one deletion occurred. This is generally not called until any pending evaluation finishes, at which point it is only called once (per «attTracker») even if there were multiple deletions during the evaluation.
The «attTracker» keeps track of which attribute of which object changed, but it does not save the value before or after the change. Essentially it enables you to figure out whether a given attribute of a given object changed since you first instantiated the «attTracker», or since it was last reset.
Function _AttTrackerQuery( attTracker, h, atts'...' )
Parameters:
- «attTracker»: The object obtained from a call to _TrackAttChanges.
- «h»: (Optional): A handle to the object of interest.
- «atts»: (Optional) The attribute(s) to query.
Use this function to figure out what has changes since the «attTracker» started tracking or was last reset.
When both «h» and «atts» are omitted, it returns a list of handles to all the objects with any attribute changes.
When «h» is specified, returns True
if it has any changes to any of the tracked attributes, False
otherwise. It array abstracts so «h» can also be an array of handles.
When «h» is omitted but «atts» is specified, it returns a list of handles to objects with a change to any of the tracked attributes that are in «atts».
When both «h» and «atts» are specified, returns True
if there was a change to any attribute in «Atts» of the object pointed to by «h».
Function _AttTrackerReset( attTracker )
Clears the log of changes inside the «attTracker», thus starting the tracking over.
Enable comment auto-refresher