09-15-2016 05:55 PM - edited 09-15-2016 05:57 PM
I have a case structure which is configured with a String selector. When I try to add the case "N\A" LabVIEW changes it to "N\n". I tried adding "N\a" and LabVIEW replaces it with "Na".
If I use selector "N\\A" it catches N\A, so it seems like it requires an escape character. It seems like the display style of the case structure isn't what I'm expecting, but I don't see a way to explicitly set it, like I can with an integer selector.
Assuming I'm on the right track with the display style, I still am not reconciling why "N\A" gets replaced with "N\n" A regular string control set to \ Display will also convert "\A" to "\n". Can someone explain this to me or point me to the documentation?
09-15-2016 06:34 PM
Interesting...It looks like the string case selector is always in \ Codes mode. The "\a" to "\n" makes sense to me since \a is actually character 0xA = Line Feed.
After digging for a little bit, the \ Codes is mentioned under the "Enumerated Values" section of the table in the "Entering Values for Each Case Structure Subdiagram" help page.
09-16-2016 03:32 PM
I may be being picky here but I assume your "N\A" case is short for "Not Appropriate" ?
Shouldn't that be abbreviated as N/A (forward slash) not N\A (back slash)
BTW: The forward slash works fine as a case
09-16-2016 03:40 PM
@RTSLVU wrote:I may be being picky here but I assume your "N\A" case is short for "Not Appropriate" ?
Shouldn't that be abbreviated as N/A (forward slash) not N\A (back slash)
BTW: The forward slash works fine as a case
Your assumption is right. And it should be N/A, but I cannot count on my field engineers not to type N\A or NA, so I was putting those all in the selector.
09-16-2016 03:42 PM - edited 09-16-2016 04:02 PM
@elset191 wrote:
@RTSLVU wrote:I may be being picky here but I assume your "N\A" case is short for "Not Appropriate" ?
Shouldn't that be abbreviated as N/A (forward slash) not N\A (back slash)
BTW: The forward slash works fine as a case
Your assumption is right. And it should be N/A, but I cannot count on my field engineers not to type N\A or NA, so I was putting those all in the selector.
You know that is what the "Default Case" is for, right?
Any case selector not defined will use the default case.
09-18-2016 06:48 PM
@RTSLVU wrote:You know that is what the "Default Case" is for, right?
Any case selector not defined will use the default case.
Unfortunately, that will also accept "asl;dkhgdsk;h f;kajshd fklashfdklj;c" unless you actually handle that string. Default should usually be an error when dealing with input strings. But from what I have been able to find, the case should be "N/A","N\\A","NA" and preferably with the case insinsitive option selected for the case structure.
09-18-2016 07:58 PM - edited 09-18-2016 07:59 PM
@crossrulz wrote:
But from what I have been able to find, the case should be "N/A","N\\A","NA" and preferably with the case insinsitive option selected for the case structure.
Yes, standard rules for escaping special codes apply (should be mentioned on the help page!)
09-19-2016 09:14 AM
@RTSLVU wrote:
@elset191 wrote:
@RTSLVU wrote:I may be being picky here but I assume your "N\A" case is short for "Not Appropriate" ?
Shouldn't that be abbreviated as N/A (forward slash) not N\A (back slash)
BTW: The forward slash works fine as a case
Your assumption is right. And it should be N/A, but I cannot count on my field engineers not to type N\A or NA, so I was putting those all in the selector.
You know that is what the "Default Case" is for, right?
Any case selector not defined will use the default case.
Default is pretty much the opposite of what I want in this case. N/A and its derivatives is the only explicit case, with everything else being handled as default. That way I don't have to make a case for every instrument name we might ever use.
09-19-2016 09:22 AM
I would add some error check either where the code is entered into a string, or on the string before the case structure that searches for N\A or any of its variants and replaces them with N/A.
09-19-2016 09:50 AM - edited 09-19-2016 10:00 AM
@elset191 wrote:
@RTSLVU wrote:
@elset191 wrote:
@RTSLVU wrote:I may be being picky here but I assume your "N\A" case is short for "Not Appropriate" ?
Shouldn't that be abbreviated as N/A (forward slash) not N\A (back slash)
BTW: The forward slash works fine as a case
Your assumption is right. And it should be N/A, but I cannot count on my field engineers not to type N\A or NA, so I was putting those all in the selector.
You know that is what the "Default Case" is for, right?
Any case selector not defined will use the default case.
Default is pretty much the opposite of what I want in this case. N/A and its derivatives is the only explicit case, with everything else being handled as default. That way I don't have to make a case for every instrument name we might ever use.
I guess I kind of see your point, I think I did something similar before for configuring instruments in a test rack, but I guess I feel the other way.
Since different instruments need to use different VI's to control them, (For instance in my test systems there could be any of three different DC power sources so there is a case for every possible instrument) the "None" or in your case "N/A" is my default case, and does nothing.
That way it is fail safe if someone fat fingers in a configuration error.