NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert step to given position ?

Solved!
Go to solution

Hi,

I have sequence with Select Case structure and want to insert steps within Case-End. How to do that ? I found that index of step can be readable by TS_SequenceGetStepIndex(SequenceHandle, &errorInfo, szTestType, TS_StepGroup_Main, &val), but how to insert new step after, for example Case ? For function TS_SequenceInsertStep (SequenceHandle, &errorInfo, actionStep, iNumofSteps, TS_StepGroup_Main) is not available index (iNumofSteps is zero and not work as index of step and can only apply for order of inserting of steps (first step on begin or to end)).

 

Currently I create all (Select, Case, End and steps that need to be within Case-End), but if basic structure can be as default (including Select, case etc), only content need to be updated, not all construction.

 

(CVI/LabWindows coding)

 

best regards,

branar

0 Kudos
Message 1 of 5
(2,926 Views)

If I understand you correctly, you want to have a sequence with a Select step and multiple Case/End steps and you want to insert steps within specific Case/End blocks. I'm assuming the problem is that when you try to get the step index for a "Case" step, you will always get the first instance. 

 

I think you need to iterate through all of the steps in your sequence and check both the Step.Name and Step.ItemExpr properties to determine whether the step is the Case step you need.

0 Kudos
Message 2 of 5
(2,841 Views)

Hi,

I understand that case or select need to be localized (it not be a problem, because I can add some Label to identify what need to be add there), but question is how to continue (just TS_InsertSequenceStep ?) with new steps right there ? Or TS_SeqContextSetNextStepIndex or some other function to tell where to start with new inserted steps ?

 

best regards,

branar

0 Kudos
Message 3 of 5
(2,829 Views)

Have you tried using the function, Sequence.InsertStep ( stepToInsert, index, stepGroupParam)?

 

The second parameter index (zero based) specifies the location where to insert the step in the step group.

 

versions used: CVI 2010, TS 2010 SP1

0 Kudos
Message 4 of 5
(2,815 Views)
Solution
Accepted by topic author branar

Hi All,

 

Yes, it was right solution. Only thing is that need to take iNumofSteps for step before and if you want to insert new step (or steps), this index shold be increased by 1.

error = TS_SequenceGetStepIndex (SequenceHandle, &errorInfo, "TuningTimeAfterLNA", TS_StepGroup_Main, &val);		
				iNumofSteps=val+1;		
					//add
		 			tsErrChkMsgPopup( TS_EngineNewStep (EngineHandle, &errorInfo, "", "Label", &actionStep));
					tsErrChkMsgPopup( TS_StepSetName ( actionStep, NULL, szTestType));							
					tsErrChkMsgPopup( TS_SequenceInsertStep ( SequenceHandle, &errorInfo, actionStep, iNumofSteps, TS_StepGroup_Main ));

 best regards,

branar

  

0 Kudos
Message 5 of 5
(2,776 Views)