NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed dynamically writing to local variables

Solved!
Go to solution

Hi folks

 

I am using a numeric limit test

The test is within a loop, and the current iteration is stored in a local variable

I am entering an expression in the Post-Expression field, and need to achieve the following:

 

If step fails, variable[iteration.local].local = Fail

 

So for example:

 

If step fails, variable1.local = Fail

 

This allows me to identify in which iteration the failure occurred, so I can record the result against the correct DUT in the batch that is looping.

 

Can someone tell me the required syntax to achieve the statement?

 

Thanks!

0 Kudos
Message 1 of 8
(2,360 Views)
Solution
Accepted by topic author Tom0000

Is this array variable a Boolean?  A String?  If a Boolean, then you could simply use Locals.Variable[Locals.x] = Step.Result.PassFail in the Post Expression. If a string, you could use Locals.Variable[Locals.x] = Step.Result.Status in the Post Expression.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(2,326 Views)

Ah great, yes a boolean is fine thanks for the syntax I will try that!

0 Kudos
Message 3 of 8
(2,299 Views)

Hi, the following didn't work:

 

Locals.Variable[Locals.x] = Step.Result.Status

 

I got the following:

 

Unknown variable or property name 'Locals.Variable'.[Error Code: -17306, Unknown variable or property name. ]

 

Basically it did not insert the number from the variable in the square brackets and match the aimed variable.

 

How can I get that number in there? I have a loop that runs 6 times, and need it's iteration on the end of that local variable name, in order to store the result for each DUT in it's own variable.

 

Thanks!

0 Kudos
Message 4 of 8
(2,198 Views)

Assuming you just configured the Numeric Limit Test to Loop:

 

Locals.Variable[RunState.LoopIndex] = Step.Result.Status

 

 

0 Kudos
Message 5 of 8
(2,189 Views)

Hi

 

The numeric limit test itself does not loop, but it sits in a much larger loop where each DUT runs all it's tests, then loops 6 times for 6 DUTs. So I just need the current DUT number on the end of the local variable, allowing me to store each DUT result in a unique variable.

 

Thanks!

0 Kudos
Message 6 of 8
(2,180 Views)

@Tom0000 wrote:

Unknown variable or property name 'Locals.Variable'.[Error Code: -17306, Unknown variable or property name. ]


That error points more to you didn't have that variable (Locals.Variable) declared or it is not defined as an array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 8
(2,165 Views)

Great, thanks!

0 Kudos
Message 8 of 8
(2,140 Views)