NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a new FileGlobal property in a TestStand step

I am trying to make a TestStand step that will create a new FileGlobal property, with the step having a precondition that the property does not exist. I found a function that will check if a property exists, so I can make the precondition. However, I could not find any way to create a new property during execution. How can I do this?
0 Kudos
Message 1 of 4
(3,599 Views)
Hi,

Using the SequenceContext as a reference, get a reference to a PropertyObject use by the method SequenceContext.AsPropertyObject().

With this PropertyObject reference you can then check if the property exists by calling the method PropertyObject.Exists(lookupstring, option). This will return a boolean.

Using the same PropertyObject reference you can use one of the SetVal methods depending on the type, eg SetValBoolean for a boolean type.

Make use of the options to create the property if it doesn't exist, when you perform the SetVal method.

If you are doing this inside a code module, you will beable to perform everything in your code.

If you are using the ActiveX adapter to call the TS API direct, then you can use an expression in the Pre-condition of you step to check if exists. Eg Exists("FileGlobals.MyVar") == True

Hope this helps
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 4
(3,587 Views)

I am trying to create new FileGlobals properties and then save it to sequence file. The only option I found is the one you propose here, but the main problem is that they are created in execution and they only exist in execution.

 

Currently, I'm evaluating 2 options:

 

-         From an external application using TestStand 3.5 API, edit a sequence file in order to create new FileGlobals, if they don’t exits, and then save the sequence file.

-         Create a TestStand step to create new fileglobals in execution but keeping them after sequence execution end.

 

Is it possible? Because I was not able to find such a solution in TestStand help/examples.

 

Thanks!


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

Hello essancla,

 

We have an article that explains how to programmatically create File Globals.

 

How Can I Programmatically Create Sequence File Globals?

http://digital.ni.com/public.nsf/allkb/4D14755C3FBCEAD486256D10007359E2?OpenDocument

 

The only thing you will want to do differently is in step two of that article.  For the setVal function you use one of the parameters is Option and you will want to pass in: 1 OR 4

If you look in the help for PropertyOptions:

http://zone.ni.com/reference/en-XX/help/370052G-01/tsapiref/reftopics/propertyoptions/

 

You'll see that 1 refers to "PropOption_InsertIfMissing" and 4 refers to "PropOption_DoNothingIfExists".  By using those options you won't have to first check if the File Global does not already exist and it will not override File Globals that already exist.

 

 

 

Kristen
National Instruments
0 Kudos
Message 4 of 4
(3,308 Views)