NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with 'For Each' loop on 'ResultList'

Hi,
 
I'm working on a task to wirte a simple text report that will list ONLY the tests of the main sequence and their resutls.
In order to do so, I wrote a subsequence called from the MainSequence Cleanup section to do this job.

in this subsequence I loop on the result of the test like this:

            RunState.Caller.Locals.ResutlList

This list contains the step name, step group, status.  Thus, I can select only the steps of the mainSequence and print those in a file.

The problem is in the loop:

I use 'For each' step type and I loop on the ResultList elements.  The last component of the array has no data, and thus, give me run-time errors. 
I want to  leave it out of the loop.

How do I do that  ?

Thanks
Rafi
0 Kudos
Message 1 of 5
(3,309 Views)
Hello Rafi,

the last element of array "RunState.Caller.Locals.ResutlList" is empty and
TS returns a run-time error, i think it is because the last step is still running, and its result is not added into array yet.

could you tell me, how did you iterate over all elements of ResultList array? Is it
from "RunState.Caller.Locals.ResultList[0]" to "RunState.Caller.Locals.ResultList[GetNumElements(RunState.Caller.Locals.ResultList) - 1]"?
Regards
MY
0 Kudos
Message 2 of 5
(3,305 Views)

Hi Rafi,

I'd stay away from using the For Each loop.

Try using a For loop and use GetNumElements() to set the number of times the For loop runs to get data from the array.

I had a problem with the For Each loop generating a Array index out of bounds Run-Time error.

I hope this helps.

Big_Will

0 Kudos
Message 3 of 5
(3,291 Views)

I adopted your advice....thank you.

 

Another question....where  in the context is the list of selected steps?

I looked at  RunState.InitialSelection.SelectedSteps  and it's empty

 

Thanks

 

0 Kudos
Message 4 of 5
(3,281 Views)
Hi Rafi,

Which Execution Entry Point did you use? "Run Selected Steps" or ""Run Selected Steps Using Single Pass"? If "Run Selected Steps", the "RunState.InitialSelection.SelectedSteps" should be correct. But for "Run Selected Steps Using Single Pass", the selected steps are stored in "RunState.Root.RunState.InitialSelection.SelectedSteps".
Regards
MY
0 Kudos
Message 5 of 5
(3,266 Views)