From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

PropertyObject Container Name

Why is the name of the StationGlobals container "Data"?  (i.e. NameOf(StationGlobals))

 

I am attempting to get the name of a container (specifically StationGlobals) in order to report an error to the user in a generic way.  I expected the name to be StationGlobals.  Is there a way to get the name "StationGlobals" given its PropertyObject?

 

I'm trying to display an error such as "[ContainerName].PropertyName" is invalid....   I don't feel that "Data.PropertyName" would be meaningful in the case of StationGlobals.

 

Your help is appreciated.

0 Kudos
Message 1 of 4
(4,185 Views)

The problem is that the StationGlobals subproperty of the sequence context is really an Alias object to the Data object of the StationGlobals PropertyObjectFile. If when getting the container, you use the PropOption_ReferToAlias option, you can get the Alias itself who's name is actually StationGlobals. For example:

 

ThisContext.AsPropertyObject.GetPropertyObject("StationGlobals", PropOption_ReferToAlias).Name

 

I'm not sure what makes the most sense for your use case, because I'm not sure how you are getting your containers to begin with, but in general, if you are using the PropertyObject APIs, you can use the PropOption_ReferToAlias option when getting subproperties to make sure you are getting Alias properties rather than their underlying properties.

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 4
(4,168 Views)

Thanks Doug... I was unfamiliar with the aliasing system.

 

In my situation if a PropertyObject is an alias object (IsAliasObject) I wish to get its alias name (i.e. StationGlobals).

 

I have a set of functions that manage PropertyObjects in a generic way.  To handle errors I need to display to the user the name of the property that caused the error.  Thus if there is a property that causes an error under StationGlobals I want the error message to include the name StationGlobals.  The functions don't know where the PropertyObject came from.

 

Is there a way to determine the alias name given only the PropertyObject?

0 Kudos
Message 3 of 4
(4,164 Views)

@TerrenceJ wrote:

Is there a way to determine the alias name given only the PropertyObject?


No, the object doesn't know about Aliases that point to it, and there can be more than one that point to the same object. You have to go the other direction and start from the top down in order to get the names of aliases in the property path. Where is the object you are doing this on coming from? If it's from an expression or parameter why not use the expression or parameter value as the location in your error message? Perhaps there is another way to do what you are trying to do. If you give us more details about where the object is coming from, we might be able to suggest an alternative.

 

-Doug

0 Kudos
Message 4 of 4
(4,146 Views)