NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to access a conditional expression of IF-step via API?

Solved!
Go to solution

If we have a flow control step IF then we can access it's conditional expression via:

 

RunState.SequenceFile.Data.Seq["MainSequence"].Main["IF"].ConditionExpr

 

How to access this expression if we don't know the step type beforehand? I'm creating some kind of static expressions checker. I access a step via

 

RunState.InitialSelection.SelectedFile.Data.Seq[Locals.seqIndex].GetStep(Locals.stepIndex,Locals.groupIndex)

 

and if

 

RunState.InitialSelection.SelectedFile.Data.Seq[Locals.seqIndex].GetStep(Locals.stepIndex,Locals.groupIndex).StepType.Name == "NI_Flow_If"

 

then I want to apply Engine.CheckExpression method to the conditional expression of IF-step

 

0 Kudos
Message 1 of 3
(3,001 Views)
Solution
Accepted by maksya

Hey maksya,

 

Attached is a sequence file with an flow control if statement, that checks to see if the step is an "NI_Flow_If" by using:

 

RunState.SequenceFile.Data.Seq["MainSequence"].GetStep(0, StepGroup_Main).StepType.Name == "NI_Flow_If"

 

If it is, it will then call check expression on the current ConditionExpr:

 

RunState.Engine.CheckExpression(ThisContext, RunState.SequenceFile.Data.Seq["MainSequence"].GetStep(0,StepGroup_Main).ConditionExpr, 0, Locals.errorString, Nothing, Nothing)

 

You'll notice that this expression is not valid, and this is because "ConditionExpr" is not valid for all step types.  However, because this step will only run IF the step is an NI_Flow_If, the expression will become valid at run-time.

 

Also is that I changed from using InitialSelection.SelectedFile to SequenceFile just to make the test easier to setup.  However, it will be the same for your SelectedFile.

 

 

 

 

Eric S.
AE Specialist | Global Support
National Instruments
Message 2 of 3
(2,960 Views)

Great thanx, Eric! You helped me a lot.

0 Kudos
Message 3 of 3
(2,950 Views)