Invalid TestStand Enumerations
- Updated2025-03-28
- 1 minute(s) read
Invalid TestStand Enumerations
Most TestStand API prevents enumeration instances from becoming invalid. Nevertheless,changing the type definition can make existing instances invalid. For example, if an enumerator is deleted from the type definition, any existing instances set to that enumerator become invalid. Changing the flags and strict/loose setting can similarly render existing instances invalid.
Assigning new values to invalid enumerations is possible. Conceptually, this behavior is similar to initializing an uninitialized variable in a language like C++. It does not matter whatthe value used to be after you set the new one.
In most cases, attempting to obtain or use the value of an invalid enumeration results in a runtime error. Methods such as GetValString() and GetValNumber() fail when invoked on invalid enumerations. TestStand expression operations, such as the equality operator (==), result in runtime errors for invalid enumerations as well. Similarly, passing an invalid enumeration to a code module via the adapters results in a runtime error.
One exception to this rule is PropertyObject.GetDisplayNames. When you callPropertyObject.GetDisplayNames on an invalid enumeration, the output valueDisplayNamestring parameter indicates the internal state of the enumeration and that it is invalid.
Another exception is serialization methods. Property object files and sequence files can be saved or read even if they contain invalid enumerations. PropertyObject.GetXML orPropertyObject.SetXML work with invalid enumerations if you pass theXMLOption_AllowInvalidObjects option.