NI TestStand Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
warren_scott

select case should support multiple values

Status: Completed
I'm happy to announce that this feature is included in the now released NI TestStand 2013! For more details on the feature or to download the new version and give it a spin, check out www.ni.com/teststand/whatsnew

For some reason I was certain this was already in the idea exchange, but I couldn't find it -- so I'll post it.

 

Select Case structures are frustratingly difficult to use if you want one case to support multiple values.

 

In text languages you can often do something like

 

Switch (Foo) {

Case 1:

execute this code;

Case 2:

execute this code;

Case 3:

Case 4:

Case 5:

execute this code;

Case 6:

execute this code;

Default:

execute this code;

}

 

Notice that the case for 3,4,5 is all the same, and I just need to put it in place once.

TestStand can't do this.  You need to do something like this:

how to do select case on multiple values

which is horribly difficult to write, maintain, and understand what is happening.  It would be MUCH easier if select case on multiple values worked like this:

SelectCaseImplementA.png

where it looks just like other text based languages, although it takes up quite a bit of realestate on the screen.

or maybe something like this:

SelectCaseImplementB.png

where I can just type in a comma separated list of allowed values.  The similarity with text based languages disappears here, but it is much smaller on screen (but notice how it shows nicely in the description field) and lines up better with LabVIEW notation.

 

 

Note: LabVIEW already supports doing this, and also supports ranges of values (eg 3, 5..10, 12 for numerics) which would also be nice, and also supports case sensitive and insensitive comparison for cases. 

5 Comments
crossrulz
Knight of NI

I like the idea of mimicing the syntax of the LabVIEW case structure.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Josh_W
Active Participant

I propose using an array where if the value matches any value in the array then the case executes. Additional text "pass array to match multiple values" would be added to the dialog/step pane.

 

There is already precident for this behavior in TestStand steps.

  • In the Queue step, if an array is specified when dequeueing, TestStand will dequeue from the first available queue.
  • The Lock and Notification steps allow arrays to be passed to operate on multiple items.

I think this would work better than a comma separated list, because commas already have a different meaning in a TestStand expression.

Josh W.
Certified TestStand Architect
Formerly blue
Lars_L
NI Employee (retired)
Status changed to: In Beta
 
MimiKLM
Active Participant

I'd like to ad an extension to this thread. I've spotted dangerous error (dangerous because is difficult to track).

 

Description:
Case statement allows multiple elements to fill in, however it doesn't match them. Regrettably, instead of throwing an error, it allows the data to be written and parsed its syntax positively, misleadingly leading to very difficult error to be captured.

 

___9e45aafe55790603378762ec623a8ad0.png

 

 

It is ambiguous. It shall thrown an error, even if the docs says that only case allows only one element to do the match.

 

And the hint: "Value to Compare (examples:3.14159, ..." in the step settings misleadingly suggest that comma separation is OK.

 

Could you please pay attention to the comments as well in the next release, please?

 

Lars_L
NI Employee (retired)
Status changed to: Completed
I'm happy to announce that this feature is included in the now released NI TestStand 2013! For more details on the feature or to download the new version and give it a spin, check out www.ni.com/teststand/whatsnew