LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling A Case Structure with String Numbers.

Solved!
Go to solution

Hello all.

 

I'm trying to use 5 digit string numbers as they come out of a Visa Read, to control my case selector for the case corresponding to the frequency. There will be numbers that don't have a case, but I want to include these in the case panel.

 

According to what I could read about it, in order to use case 00050 for all the numbers up to the next case (00950), I would make the first label say "00050..000950" (no spaces).  If I did this to all the cases the test LED's representing each case would systematically turn on at the lower case until the number reached the next case and turn off, followed by that cases LED turning on and so on up the ladder. (This is the case in the middle with all the test LED's connected to it.)

 

 

Labview block.pngWhen I did this, instead of just getting a test blink only on the 00050 freq case, and every other frequency case, all the test led's stopped. 

0 Kudos
Message 1 of 36
(6,217 Views)

Copy the case and the indicators to a new VI, and use a FP string control to be able to key in the strings that you ar using to drive the case structure. Watch it in execution-highlighting mode.

 

I can only guess that the default case is being invoked.

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 36
(6,202 Views)

I am afraid you may be right Ben, I was hoping that ".." between the numbers would keep it away from the blank default case. The Frequency numbers start at 00050 and go up by a hundred every number. 00150, 00250, 00350.. until the last is 19950. But I only care about 20 of the frequencies along the way in order to refresh the sensor Cal Factor as I increase in Frequency.

 

I will do this and Report.

Thanks!

Message 3 of 36
(6,195 Views)
Solution
Accepted by topic author Hobbs23

You'll need to convert the string to a number and then do the range comparison.  The ".." only works with integers.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 4 of 36
(6,183 Views)

Maybe you want to scan the string into an I32 integer and use that to drive the case. Now you can use ranges.

 

However, you can also use leave the .. out of the doublequotes, and it will use alphabetic sorting. Should work with your zeropadded values.

Message 5 of 36
(6,181 Views)

@altenbach wrote:

 

However, you can also use leave the .. out of the doublequotes, and it will use alphabetic sorting. Should work with your zeropadded values.


 

textranges.png 

 

Any key that would fall alphabetically between the range edges will match.

(other case is default).

Message 6 of 36
(6,174 Views)

You can specify a range of a..c and it will evaluate all input values that start with letters in that range but a selector value of "17950..19950" is only going to evaluate as true when the input value is the literal string "17950..19950".

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 7 of 36
(6,172 Views)

@altenbach wrote:

textranges.png 

 

Any key that would fall alphabetically between the range edges will match.

(other case is default).


The first letter of the range is inclusive but the last is not.  "D" will not match. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 8 of 36
(6,158 Views)

@aputman wrote:
The first letter of the range is inclusive but the last is not.  "D" will not match. 

Thanks, so it need to be tweaked a little. 😄 (yes, this is documented. Never run across it 🐵

 

For example we might change the range to ["A".."D "] (notice the space) or ["A".."D0"] . Both seem to work and include "D". The OP deals with only numerical characters, else we might also need to handle case (in)sensitivity as needed.

Message 9 of 36
(6,142 Views)

altenbach wrote:

 

Thanks, so it need to be tweaked a little. 😄 (yes, this is documented. Never run across it 🐵

I'm acting like I knew all about it but I came across it in the documentation as well.  Smiley Wink

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 10 of 36
(6,096 Views)