I am developing a script that shows FileGlobals variable inside a small C# interface, a sort of debugging view to keep track of a couple of variable while testing units.
I managed to display an Array of number that shows as is in TestStand:
The corresponding C# script is as follow (ObjectList is in FileGlobals):
private NationalInstruments.TestStand.Interop.API.SequenceContext mSequenceContext; this.objList=this.mSequenceContext.FileGlobals.GetPropertyObject("ObjectList",0); double myArray = (double)this.objList.GetValVariant("", 0); this.testLabel2.Text = myArray.ToString() + " " + myArray.ToString();
In the label I can read "1 5", great success !
Now I want to reproduce the same thing but with an Array of Object References, here seen in TestStand:
Should I also start with this.mSequenceContext.FileGlobals.GetPropertyObject ? Does this work as a general approach to retrieve any object?
I'm a bit lost when it comes to what to do after that, any help much appreciated.
If you look at the API for property objects there are a whole bunch of GetValXXX and SetValXXX methods. https://zone.ni.com/reference/en-XX/help/370052AA-01/tsapiref/reftopics/propertyobject/
Some of them say GetValxxxByOffset. These are used to index arrays. In your case you could do:
this.obj = this.mSequenceContext.FileGlobals.GetValIDispatchByOffset()
Hope this helps,
Right ok, I think I got to that point some other way but this.obj is just a C # object and I could not find a way to retrieve the value of what it was pointing to.
Got it ! To display first element:
this.objList2 = this.mSequenceContext.FileGlobals.GetPropertyObject("ObjectList2", 0); private NationalInstruments.TestStand.Interop.API.PropertyObject t; dynamic v = this.objList2.GetValVariant("", 0); this.t = (NationalInstruments.TestStand.Interop.API.PropertyObject)v; t.GetValNumber("", 0).ToString(); // here is the value !