03-25-2019 01:07 PM - edited 03-25-2019 01:23 PM
This is a two-part question, both pertaining to step variables:
1) Is there a way to programmatically (C#) create a new step variable when dragging and dropping a custom step into the steps window? I created the step type, set up the OnNewStep substep (which calls a form in a C# code module) and am able to set Locals and FileGlobals, but not Steps. I did notice that the steps don't seem to appear in the Steps window until after the form closes, so is it even possible to create it at that point?
I am looking to do something like this:
SequenceContext.Step.CreateValString("MyStepVariable", "SomeValue);
2) How would I edit an existing step variable. Let's say I already have the variable created (some other way). Is there a way to change its value in code? I see the SequenceContext.Locals and SequenceContext.FileGlobals. However, I am unable to find anything that would work like this:
SequenceContext.Step.SetValString("MyStepVariable", "Hello");
FYI, neither of these are meant to run when the step actually runs. They would be called when adding or editing a step.
Thanks a ton in advance for any and all suggestions.
Solved! Go to Solution.
03-25-2019 06:00 PM
If you can pass the step object in as a parameter (property object) then you should be able to do what you need. I just tested it.
03-25-2019 06:11 PM
So I just tested with SequenceContext going into my OnNewStep substep. I only know LabVIEW (sorry) so I was doing it in LV.
Basically I used the Get TestStand Property to get a Property Object. My lookup string was "Step" (relative to Sequence Context). Then I typecast the Proprty Object to Step type using the TS API. (in LabVIEW we use variant to data, not sure about C#), After that I just use the SetValString("New String Name", 0x1, "Value"). You need the 1 to create the variable.
Hope this helps,
03-26-2019 07:43 AM
Yup, calling the AsPropertyObject() method seemed to do the trick:
mySequenceContext.Step.AsPropertyObject().SetValString("MyStepVariable", 0) = "Whatever";
Thanks for your help!