NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how to set up a case statement to take multiple values in teststand

I am using a select with multiple case statements.  I am using one of the case statements to be used for multiple expression results.  Specifically, the expression is a string and I want the same case to operate for values "1" and "4", but I can not find the syntax for this, does anyone know it?

0 Kudos
Message 1 of 7
(13,936 Views)

Does the example UsingFlowControlSteps.seq in the TestStand Examples\SequenceFlow help in any way

Regards
Ray Farmer
0 Kudos
Message 2 of 7
(13,932 Views)

Not really.  I am wanting to know how I could make the same case sequence occur if either "1" or "2" was the expression.  I am looking to reduce code rewriting for the same result that comes from multiple expressions.

0 Kudos
Message 3 of 7
(13,930 Views)

Hi,

 

try this example.

 

 

Regards
Ray Farmer
Message 4 of 7
(13,922 Views)

I think you just need to put your values into an array like this...

{"1","2"}

Message 5 of 7
(11,290 Views)

In your question you include two string representations of numbers:  "1" and "4".  In addition to discrete numeric, character and logical expressions, the TestStand case statement also allows for arrays of either strings or numbers to be used when a single case needs to match more than one expression result.  Syntax for these arrays is:

 

    case {expression_1, expression_2,...,expression_n}  //matches any of the expressions contained in {...}

 

Where expression can be a numeric value or a string value. 

 

    case {"string_1", "string_2"}

and

    case {1,2,3,4,5,6,7,8}

 

are both legal case arrays

 

There is no limit on the number of expressions.

Note, unlike some extensions of the C switch:case statement, case ranges such as 5:20 (matching any value from 5 to 20) are not legal.  case arrays can only contain a number of discrete expressions

 

An example showing a numeric array can be seen in the PromptForInput sub-sequence on the second case statement <teststand directory>\Examples\Built-In Step Types\Message Popup Step Type\Message Popup Step Type - Get User Input.seq

(C:\Users\Public\Documents\National Instruments\TestStand YYYY (32-bit) is a typical path for <teststand directory>)

Message 6 of 7
(6,359 Views)

I tried entering an array of numbers, but it gave an error that it could not compare an array of numbers to the selection, which was a single integer.

0 Kudos
Message 7 of 7
(3,847 Views)