NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how to check string value using if condition

 hi,

 

I have declared variable A as a string

 

if(locals.A)!="N/A"

   passs some conditions

else

   fails.

 

 

I am getting error at if statment line...pls let me know how to compare the sting value

 

thanks,

chethan

0 Kudos
Message 1 of 9
(6,226 Views)

Locals.a!="N/A"

 

Put this in the if statement i.e.

 

if(Locals.a!="N/A")

 

If this does not   then pls attach sequence.

0 Kudos
Message 2 of 9
(6,209 Views)

thanks for your reply....

 

Sorry i didn't give complete details in previous post....

 

The requirement is as follows

 

Parameters.tar_str                    (tar_str is declared as string array under parameter)

 

Foreachloop

Array to Iterate : Parameters.xxx                                                (xxx is declared as string array)

Current element : locals.Currentelement                                     (Current element is declared as local variable)

Current offset : locals.Currentoffset                                            (Current Offset is decalred as Local variable)

 

 

locals.tar_name                                                                       (tar_Name is decalred as local string to transfer current offset string of each index)

 

locals.tar_name = Parameters.tar_str[locals.currentoffset]  -----> here i am getting error as "specified value does not have the expected type. this value will cause run-time error" 

 

Note if i use str(locals.tar_name)== Parameters.tar_str[locals.currentoffset]  --> here i don't get error , so i need to know which statement is correct

 

if(locals.tar_name!="N/A")

{

    pass some conditons

else

    fails condition

 

}

 

this is my requirement. Pls let me know the solution

 

I tried strcmp in if conditon loop but i got error...FYI

0 Kudos
Message 3 of 9
(6,204 Views)

Are you trying to use the "If' step type or are you trying to do this in a single expression. If you are trying to do this in a single expression then you need to use the conditional operator '?'.

 

It's equivalent to how that operator works in C/C++ and it works as follows:

 

(conditional Expression) ? (Expression to execute if true) : (Expression to execute if false)

 

-Doug

0 Kudos
Message 4 of 9
(6,189 Views)

as I mentioned in previous post, i want to compare using if condition step type not expression.......I would also like to know the solution wherever i am getting error whcih is explianed in my previous post.....Pls let me know.....

0 Kudos
Message 5 of 9
(6,181 Views)

Hello Mandya,

 

Have you seen the TestStand shipping example UsingFlowControlSteps.seq? This example demonstrates in detail how to set up flow control steps. The default location for this example is <TestStand>\Examples\SequenceFlow\.

 

Please take a look at this example, and adapt your application to fit the If and Else steps shown.

 

Warm Regards,

Daniel Dorroh
National Instruments
0 Kudos
Message 6 of 9
(6,157 Views)

See next post.

0 Kudos
Message 7 of 9
(6,148 Views)

regarding:

 

locals.tar_name = Parameters.tar_str[locals.currentoffset]  -----> here i am getting error as "specified value does not have the expected type. this value will cause run-time error" 

 

Note if i use str(locals.tar_name)== Parameters.tar_str[locals.currentoffset]  --> here i don't get error , so i need to know which statement is correct

 

 

It sounds like locals.tar_name isn't really a string. If it was a string you would not need to do str().

 

-Doug

0 Kudos
Message 8 of 9
(6,145 Views)

ok..thanks for you reply.....

0 Kudos
Message 9 of 9
(6,137 Views)