State Object

The State object is a named varset object. As a response to an event, alert, or performance measurement, you can save and edit state information in the State object. You can then access this state information from scripts.

There are different types of state operations. Most state operations edit a variable by incrementing it, decrementing it, or setting it to a specific value. These operations include the following operations:

These operations make the variable specified in the State variable name field available to scripts through the State object.

The Store the last N occurrences operation creates the following variables with the state variable root:

State_Variable_Root.size
Specifies the number of occurrences stored. This value is equal to the value specified in the Number of occurrences field.
State_Variable_Root.first
Specifies which State_Variable_Root.N variable contains the earliest occurrence of the variable. If State_Variable_Root.first equals 4, then the earliest occurrence of the variable is stored in State_Variable_Root.4.
State_Variable_Root.last
Specifies which State_Variable_Root.N variable contains the latest occurrence of the variable. If State_Variable_Root.last equals 2, then the latest occurrence of the variable is stored in State_Variable_Root.2.
State_Variable_Root.N
Specifies each of the occurrences of the variable. N can be 1 to the value specified in the Number of occurrences field. The occurrences cycle through the N variables overwriting the oldest occurrence. Use the .first and .last variables to keep track of the order of occurrences.

Set the operation, values, and name and root field for state operations with the State Variable Update Operation Window.

Example 1

To access the number of times an event occurred after setting a state response to increment the LogonViolations.Count state variable name, enter:

Dim MYcount

MYcount = State.Get("LogonViolations.Count")

Example 2

To access the last occurrence of the logon domain after setting a state response to record the last 50 occurrences of the Logging Domain variable with the LogonViolations.LoggingDomain state variable root, enter:

Dim MYLastOccurrence
Dim MYLastDomain

MYLastOccurrence = State.Get("LogonViolations.LoggingDomain.last")
MYLastDomain = State.Get("LogonViolations.LoggingDomain." + MYLastOccurrence)