02-25-2009 09:55 AM
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
Solved! Go to Solution.
02-26-2009 12:50 AM
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
02-26-2009 07:22 AM - edited 02-26-2009 07:26 AM
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