From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i access RunState.LoopIndex

Hi,
I am executing the test for X times by looping the step.
Is it possible to access RunState.LoopIndex variable.
 
Thanks in Advance,
Sivanath
0 Kudos
Message 1 of 6
(3,953 Views)

Hi,

How are you looping on the step?
Are you executing it interactively or you just set the number of loops in the step properties/loop options?
Remember that if you loop on the step interactively you create a new interactive execution and the RunState.LoopIndex is not updated.
If you loop on the step by setting the step's loop options you can access RunState.LoopIndex.

The easiest way to prove it is creating a sequence containing a Message Popup step and displaying the RunState.LoopIndex every time the step is executed.

See attached file.

Hope it helps.

Message Edited by Antonio Lie (NI) on 07-22-2005 01:54 PM

0 Kudos
Message 2 of 6
(3,938 Views)

Hi Antonio Lie,

I am looping the sequence using Step - Properties (LoopOptions).

Trying to access RunState.LoopIndex by Teststand API given below.

TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, "RunState.LoopIndex",  0, LoopCount);

Whether the parameter that i am passing is correct ?
 
 
0 Kudos
Message 3 of 6
(3,925 Views)
Hi Sivanath:

I'm not sure if you are using TestStand 3.1 or not. In TestStand 3.1 there is a Flow Control step called For...End. You can right click this step and configure parameters for looping here. You can define a new loop variable for Number of Loops and Loop Variable, right click on it and add it to the Locals list. Please see the example program below and let me know if you have any questions.

Nandini
National Instruments
0 Kudos
Message 4 of 6
(3,908 Views)
Hi Sivanath,
 
Yes you can use the TestStand API to access the "RunState.LoopIndex" Property.
You could also pass the property as an input parameter to your function.
In the following code I am doing both to give you an idea how it works.
I do not use the input parameter though.
 
int __declspec(dllexport) __stdcall LoopIndex_Count (CAObjHandle context, double InLoopIndex)
{
    int         error = 0;
    ERRORINFO   errorInfo;
    char loopIndexStr[1024];
    ErrMsg      errMsg;
    double loopIndex = -1;
    tsErrChk(TS_PropertyGetValNumber(context,&errorInfo,"RunState.LoopIndex",0x0,&loopIndex));
    sprintf(loopIndexStr,"%d",(int)loopIndex);
    MessagePopup("Loop Index",loopIndexStr);
 Error:  
    return error;
}
 
Check the attached example.
Hope it helps.
 
Antonio.
0 Kudos
Message 5 of 6
(3,899 Views)
Sivanath  -
I do not know if your posted code is exactly what you have in your module, but your LoopCount variable needs to be passed by ref to the GetValNumber function, i.e. &LoopCount.
Scott Richardson
0 Kudos
Message 6 of 6
(3,883 Views)