NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

No access to python function in for loop

Solved!
Go to solution

Hello

within teststand (2020) I am calling a python function. This function is running without a problem when calling several times directly from the python IDE. Now when I call the same function in a teststand sequence within a for loop, it works but on for the first loop. The second and following loops are failing with the error message:

 

<class 'IndexError'>
list index out of range

 

When I unload all modules after the first loop then all other loops are working without any problem. What could be the reason for it and/or is there a better solution?

 

Thanks in advance

0 Kudos
Message 1 of 4
(856 Views)

Norick17,

I am unable to reproduce the issue. Please provide the sample files for which issue exists.

 

-Shashidhar

0 Kudos
Message 2 of 4
(824 Views)

let me ask differently:

 

When you instantiate a python class you get an object reference inside the "Variables View". In my case I use a reference in the local variables:

 

ref.png

 

When you click on the scissor you can release the object again. Is there a way to programmatically release the object reference with Teststand??

0 Kudos
Message 3 of 4
(812 Views)
Solution
Accepted by topic author Norick17

Using TestStand expressions (like in Statement step), update the object reference so that it does not hold any data. You can do it with an expression like:

Locals.SPI_Interface = Nothing

 

Executing that expression is equivalent of clicking the scissor icon next to the variable.

 

-Shashidhar

0 Kudos
Message 4 of 4
(810 Views)