07-21-2022 10:59 AM
Hi
I want to use C# to change some values in station globals, how can I do this?
Thanks!
Solved! Go to Solution.
08-24-2022 01:35 PM - edited 08-24-2022 01:37 PM
Hi charleserr,
First, add NationalInstruments.TestStand.Interop.API to your project (right-click References >> Add Reference >> Assemblies >> Extensions >> NationalInstruments.TestStand.Interop.API).
Then add using NationalInstruments.TestStand.Interop.API to your source file.
After that; you need to add the TestStand sequence context as an argument to your method. From there, you can access all of the TestStand variables from the sequence context and modify them using the set methods. There are several different set methods available depending on the datatype of the variable you want to modify. Since this is already at the intended variable scope, the lookup string argument will just be the name of the variable. Here, I'm setting a StationGlobal named "test" that is a numeric datatype:
Then, from TestStand, pass "ThisContext" into the sequence context argument:
11-24-2022 08:00 AM
Thank you very much for your reply, under your guidance, this problem has been solved!
I also tried to modify the file type of "StationGlobals.ini" to XML, and directly edit this XML file to achieve the effect I need.