LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

skip some case structure

Hello Team,

 

I have try searching for a example on to skip certain case structure and have no luck.

I have a case structure inside of a for loop and would like to skip certain case depending on the interation.

 

For example, I have 10 cases 1 to 10 using the interation as to which case its on.

I would like to skip case 3,6, and 8.

I know I can just delete the case and not add it to the structure but in some case I would like switch different case number depending on my program.

 

Thank you,

 

H.

0 Kudos
Message 1 of 12
(3,519 Views)

Do you need these 'switched cases' to be configurable?


The simplest solution will probably be to place some code between the iteration terminal and the case structure selector node that captures those particular numbers you wish to prevent calling cases (in this example capture 3,6 and 😎 and output instead, say -1. Create a default case in your case structure that executes the '-1' case.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 12
(3,509 Views)

Given your description of what you ar edoing I wonder if you are using the best approach to solve your problem. If your case inside the For loop are simply numbers I suspect the code is not that readable since the iteration value provides very little information regarding it's meaning especially since you are skipping some of the iterations. What exactly is the purpose of the loop and the case structures? There may be a better way to implent your solution and have it more readable as well.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 12
(3,499 Views)

Yes, Im try to configure the cases.

I try putting some codes in between the case structure and iteration but FAIL at doing it.  Could you do a rough sketch in labview for me and attach it as a screen shot. 

 

Thanks

0 Kudos
Message 4 of 12
(3,497 Views)

Skip cases.png

 

 

I believe this should do what you are looking for. It will skip the cases as defined by the array.


0 Kudos
Message 5 of 12
(3,492 Views)

I have a device that needs to measure certain measurements and some devicedoesnt have all the function apply to it.

So I have a function per a case, so I need it to skip a case if the function is not applied.

I have a case number apppend to a certain function using the iteration as a way of locating what function its operating.

 

I know there is a more effiecieny way but cant get it to work atm.

0 Kudos
Message 6 of 12
(3,490 Views)

Mark is correct in stating your approach sounds less than ideal, however if you insist with this strategy you should be able to simple:

 

Place a new case structure between the iteration terminal and the existing case structure.

Wire the iteration terminal to the new case structure

Create a default case, wire the case selector terminal straight through and out the right hand side.

Create a case called "3, 6, 9" and output a numerical constant set to -1.

Wire this case structure's numerical output to the case selector of the original case structure.

 

This way the iteration values of 3, 6 and 9 will be changed to -1, all other cases will be unaffected.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 7 of 12
(3,482 Views)

It would seem that a state machine might be a better option since it will be more readable. Another alternative would be to generate an array of ENUM's (typedefed of course) which represent which functions you want to apply. As mentioned above, basic numbers provide no meaningful information to the code. Several months from now when you open the code will you remember what case 0 meant? Will someone else looking at the code have a clue? The answer to that is more likely they will not. Perhaps you can post what you have done so far and we could offer better solutions to your problem.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 8 of 12
(3,478 Views)

I try using the ENUM's, didnt work like as I planned.  So im trying to using the iteration in replaced of the enum.  My first idea was to used a boolean case structure for each function if it was apply or not with a string to define which function it was then just a number.  It didnt work out.

0 Kudos
Message 9 of 12
(3,462 Views)

I second Mark's comment.  A better way would to create an array of cases to apply and autoindex the array.  And type def you enum to make life a lot easier.


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
0 Kudos
Message 10 of 12
(3,460 Views)