NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing local variables of a sequence from the sequence calling it

Hi,
I am looking for a way of accessing the local variables (or even the entire context) of a sequence from the calling sequence. The called sequence is run in a new thread. In my test I call the same sequence many times and would like to keep most of the variables in this step to simplify maintenance since those variables will only be defined in one place. After running all those sequences, I will add a few test steps using the local variables of the previous sequences. I would like to have something like RunState.Sequence.Main.MySequence1.Locals.MyVar1, RunState.Sequence.Main.MySequence2.Locals.MyVar1, etc. to access the variables. Therefore in the future when I add new locals to my sequence I wont have to update a whole bunch of sequences. So is there a simple way to do that, or something close to it?

Thanks!

Louis
0 Kudos
Message 1 of 6
(3,806 Views)
Louis -
Here is the general idea.
1) You could create a container, i.e. Locals.Thread1.Locals in the calling sequence.
2) In the setup group of the called sequence, you could use the ActiveX adapter to call SetPropertyObject("Thread1.Locals", PropOption_NotOwning, RunState.Locals) on the "RunState.Caller.Locals" object. This will change the Locals.Thread1.Locals property in the calling sequence from a container to an alias object that points to the called sequence's locals. Even when the thread completes, the Locals.Thread1.Locals variable will point to the old copy of the called sequences locals. Look at the PropertyObject.IsAliasObject help for some discussion on alias objects.
Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 6
(3,803 Views)
For the 1st option, if I understand correctly I will create an empty container in the calling sequence, pass it by ref to the called sequence and fill it up with the local variables. Is there a simple way to put all my local variables in this container?

Thanks!

Louis
0 Kudos
Message 3 of 6
(3,794 Views)
Hi Louis,

Actually, the suggestion by Scott is not two different options but a two step process. This will create a container that references your local variables. Therefore you need to go through both steps.

Thanks,
Caroline
National Instruments
Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 4 of 6
(3,763 Views)
Actually I've created a container with the data I wanted my sequence to get and passed it by reference to my subsequences. Then I store the data in the container which is automatically available to the calling sequence. I would have prefered not to pass data like this but it was simple enough...
0 Kudos
Message 5 of 6
(3,759 Views)

Could you put together a simple example.  I am trying to do the exact same thing

0 Kudos
Message 6 of 6
(3,259 Views)