04-15-2013 09:23 AM
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.
04-15-2013 09:35 AM
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.
04-15-2013 09:44 AM
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.
04-15-2013 09:47 AM
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
04-15-2013 09:51 AM
I believe this should do what you are looking for. It will skip the cases as defined by the array.
04-15-2013 09:52 AM
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.
04-15-2013 09:57 AM
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.
04-15-2013 09:59 AM
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.
04-15-2013 10:23 AM
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.
04-15-2013 10:24 AM - edited 04-15-2013 10:25 AM
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.