NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

parameterized access to a local variable

Solved!
Go to solution

Hi,

 

  In a sequence, I would like to access a local variable of type "container", but the container element needs to be programmatically defined from another variable (an element in an array). Basically it would look like this:

 

For each Locals.TestList                                                                      // TestList is an array of 9 strings, current element is stored in Locals.CurrentTest.

  Locals.TempVariable = Locals.ResultList.<Locals.CurrentTest>     // Locals.ResultList is a Container of

End                                                                                                        // strings. Each string variable name is the same as the elements in TestList

 

Is that possible?  What would be the syntax for the "<Locals.CurrentTest>", so that TestStand understand the variable structure?

 

Thanks,

Benoit

0 Kudos
Message 1 of 3
(3,022 Views)
Solution
Accepted by topic author BenoitProvost

Hi,

 

Locals.TempVariable = Evaluate("Locals.ResultList." + Locals.TestList[Locals.CurrentTest])

 

That might do it if I have understand your requirements correctly. The parameter of Evaluate needs to be a string so if you pass the lookup string for your container then Evaluate will return the contents from that location ie Locals.ResultList.<element name>

 

Regards

Ray Farmer

Regards
Ray Farmer
Message 2 of 3
(3,008 Views)

Thanks Ray. That worked!

 

Actually I tried the "Evaluate" function before, but it did not work at first. Since you said it should work, I gave it a second try. The trick is to initialize the string to a non-empty value at variable declaration. Otherwise the Evaluate function complains, even though the string is given a value before the Evaluate function is called when the code is executed.

 

Benoit

Message Edited by BenoitProvost on 02-26-2009 07:26 AM
0 Kudos
Message 3 of 3
(3,003 Views)