ReplaceStates Method (StateSet collection)

               

 

Replaces the DigitalStates associated with this StateSet with the passed array of DigitalState names. The StateSet is modified on the server as well as changing the in-memory representation of the collection.

 

Syntax

object.ReplaceStates NewStates

The ReplaceStates method syntax has these parts:

Part

Description

object

An object expression that evaluates to a StateSet collection.

NewStates

An array of strings which represent the DigitalStates which comprise the revised StateSet. The array should be dimensioned from 0 to one less than the number of elements passed. (for example dim saStates (0 to 7) would contain 8 strings. The array elements should be in the order desired. Codes will be assigned to the states in the order passed.

 

Remarks

This routine can be used to reorganize the DigitalStates in a StateSet. Typically this type of modification is made when a StateSet is first being specified. Note that viewing data that was archived prior to the change will reflect the new states. The ordinal position of the state is stored in the archive event and does not change. If you reduce the original number of states in the set, the string for those previously archived events whose ordinal is now out of range, will be undefined. Use the ReplaceStates method to correct this. This error can be avoided by never reducing the number of defined states in a set that has been used to archive events.

To change a single state within the StateSet use the RenameState method. To add a DigitalState to the end of an existing set use the StateSet.Add method. To add an entirely new StateSet use the StateSets.Add method.

 

Trappable Errors

In addition to generic errors (such as Out of Memory), the following errors may occur:

Error

Description

pseLOADSTATESET

Unable to load the current StateSet from the server.

pseSTATESREPLACE

Unable to replace the DigitalStates in the StateSet on the server. The error description contains more specific information.

Enabling Operational Intelligence