Discussion:
Delete multiple StationGlobals using DeleteSubProperty
(too old to reply)
NGupta
2008-07-30 08:40:10 UTC
Permalink
I am using DeleteSubProperty to delete StationGlobals in Teststand. In my requirement I need to delete more than one StationGlobals starting with same name e.g I want to delete all StationGloabls starting with name "a". Is it possible using DeleteSubProperty using it only once? I am using TestStand Ver 3.5
Ray Farmer
2008-07-30 09:40:15 UTC
Permalink
Hi,
Simple answer - No.
Regards
Ray Farmer
NGupta
2008-07-30 14:40:21 UTC
Permalink
So is it possible to delete only one stationglobals but using wild character?
e.g If I need to delete stationglobals named "a1". Can I use it like delete "a*.*" or something like this.
Actually in my requirement I am not sure what is the name of stationglobals. I only know the initial name of the stationglobals.
I need to delete it.
Josh W.
2008-07-30 20:10:12 UTC
Permalink
One possible way to do this will be to use the <a href="http://zone.ni.com/reference/en-XX/help/370052F-01/tsapiref/propertyobject_search_m/" target="_blank">PropertyObject.Search() </a>method.
If you run this method on the StationGlobals property object, you can use <a href="http://zone.ni.com/reference/en-XX/help/370052F-01/tsapiref/searchoptions/" target="_blank">SearchOptions_RegExpr</a>&nbsp;to specify that your search string is a regular expression.&nbsp; Regular expressions can match multiple values.&nbsp; TestStand will then return a <a href="http://zone.ni.com/reference/en-XX/help/370052F-01/tsapiref/searchresults/" target="_blank">SearchResults </a>object that is a collection of all of the matching PropertyObjects.&nbsp; Once you have an individual <a href="http://zone.ni.com/reference/en-XX/help/370052F-01/tsapiref/searchmatch/" target="_blank">SearchMatch</a>, you can use the <a href="http://zone.ni.com/reference/en-XX/help/370052F-01/tsapiref/searchmatch_getpropertypath_m/" target="_blank">GetPropertyPath</a>&nbsp;method to get the lookup string to the property.&nbsp; Then you will need to call <a href="http://zone.ni.com/reference/en-XX/help/370052F-01/tsapiref/propertyobject_deletesubproperty_m/" target="_blank">DeleteSubProperty</a>&nbsp;on the original StationGlobals property object and pass it the lookup string that was returned.
Please note that I found all of this information by looking through the TestStand help and have not tested it, so I may have left out a step or two somewhere.
Ray Farmer
2008-07-30 22:10:12 UTC
Permalink
Hi,
Just to add what Josh has said.
The SearchMatch.GetPropertyLocation(True) will probably return only a relative location from where you took the search property.
ie if you took StationGlobals as the start, and you where searching for occurrances of "administrator" then you would probably get two hits and the first would be at "TS.LastUserName" which is the returned string from GetPropertyLocation.
Also the PropertyObject.Search(...) has a number of parameters which are arrays, these can be empty or NULL. The only way I have made this work is by using a Locals array which is empty.
You can get the number of hits on your search by using SearchResult.NumMatches. You dont have to wait for the search to complete to call this so you could put this in a loop and check for IsComplete to be true.
Hope this helps
Regards
Ray Farmer
Ray Farmer
2008-07-31 06:10:10 UTC
Permalink
Hi,
Adding to my last comment.
If you use
PropertyObject.Search("", "^a", 0x4, 0x00FFFFFF, 0x1, Locals.emptyArrayStr,&nbsp; Locals.emptyArrayStr,&nbsp; Locals.emptyArrayStr, Locals.emptyArrayStr) you need to setup Locals.emptyArrayStr as an empty String Array. Use StationGlobals as the ActiveX Reference.
This should return back a SearchResult of all the Property Names beginning with "a" within the StationGlobals.
Hope this helps
Regards
Ray Farmer

Loading...