07-16-2009 09:32 AM
Hi,
Im just a novice at labview (we use labview 7.1) and I've got a problem with a case-structure I don't understand
As a novice I get to make small changes to existing programs.
In one of my quests to solve a problem I added an extra case to an existing case structure of 10 cases (thus creating case 11)
But after some experimenting I found out this was not the way to go so I emptied and deleted this last case. Creating the original situation I started out with
But after this deletion the program wouldn't run anymore. I noticed that the two point behind the 10 was missing (with other words the last case was marked as 10 and not as 10.. anymore.
I tried to fix this problem but was unsuccessful. Even my experienced collegue couldn't solve this problem
Can anyone tell me how to fix this problem (for future use)
07-16-2009 09:52 AM
Hi shaunros,
insert the two points after the 10. Did you delete the 11. case? You can do with a right click on the case structure. The case you want to delete has to be the active. Are there any open tunnels on your case structure?
Mike
07-16-2009 10:01 AM - edited 07-16-2009 10:02 AM
Can anyone tell me how to fix this problem (for future use)
Well, you can use your backup copy (HINT, HINT, HINT :-).
Understand a few rules about CASE structures:
1... There has to be a case covering any possible value the selector could receive. It doesn't matter that you're only using 0-11, if it's an I32 selector, you have to cover all 4 billion possibilities.
2... YOu can specify values separated by commas, like "1,3,5,7".
3... You can specify a closed range with two dots, in between the first and last values, i.e. "0..9".
4... You can specify an open range with two dots after, or before, a value. "..4" means any value that is 4 or below, "11.." means any value that is 11 or above.
5... You can use the magic word "Default" to mean "any value I haven't covered in another case".
Blog for (mostly LabVIEW) programmers: Tips And Tricks
07-17-2009 01:19 AM
Hi Mike and Steve
I had a copy of the program (before I added the extra case, the original program) so I could show it to my collegue.
I opened the program, added an extra case (put nothing in it) and deleted the case again (with the option "delete this case")
And I had reproduced my problem
regards shaun
07-17-2009 01:23 AM
Hi shaun,
can you upload your vi?
Mike
07-17-2009 04:00 AM
Hi Mike,
I've ripped out the DAQ parts from the VI so it can work stand alone.
You'll find the case selecter with the 10 cases in the centre of the program (it's a small program)
I have reproduced the problem with this test VI as follows
Go to the last case (case 10) and add a case after this one(creating case 11). Next remove the case (11) by means of delete this case
And you will see that the VI wouldn't run.
Please remember that I'm using labview 7.1
I still don't understand that if you add an extra case at the end it automatically becomes the last case but if you remove the last case the new last case doesn't automatically become the last case (what a sentence)
Let me know if you can reproduce the problem and if you know a solution (except making a back up evertime I add a case to VI)
thanx
Shaun
07-17-2009 04:09 AM - edited 07-17-2009 04:10 AM
Hi Shaun,
i can see what you mean, but i can just repair it after, deleting the 11. case, if i add the two points in the 10. case.
They can't automatically make this the last case, because you could also make another case the default case.
Mike
07-17-2009 04:37 AM
Shaun,
sadly, i am missing the subVI "Extract Numbers.vi", so i can't follow your "steps to reproduce". But i noticed that the last case is currently "10.., which represents "every value of 10 and above.
Inserting a new case "11" changes case "10.." to "10" and "11" to "11..". This is the way it works in LV 8.6.1f1.
Deleting "11.." will not change "10" back to "10..".... so maybe this is part of the issue you are running into.....
Note that a case structure may only have one case for a single input value (so "10.." and "11" is an invalid combination)
hope this helps,
Norbert
07-17-2009 05:09 AM
Hi Mike And Norbert,
I finally understand what you and the others mean.
I have to personally add two point (rename case 10 to 10..) to repair the case structure.
Damn, I've had known that.....I wouldn't have been so puzzled (and I still think it is silly that adding a case is not a problem but deleting it is)
Thanks guys for your insight
07-17-2009 05:20 AM
Hi Shaun,
Did you overlooked this one in a previous post?
5... You can use the magic word "Default" to mean "any value I haven't covered in another case".
Why don't you make Case 0 the default case with "0, Default" in the selector and forget about all those ".." before & behind case numbers??
Because now if someone enter a value 99, the last case will be executed! And that's maybe not wanted.
IF you don't want the 0 case to be the default one, just make a new case called "Default" and put nothing in it except maybe a user message "Invalid selection, please try again." or something like that. Always be nice with the user ![]()
This way you make a "Case Else" like in VB language 🙂 I always use this one to catch all possible errors.
Regards
Alain
PS: Dutch text in LV vi's
Veel succes en als je vragen hebt, laat maar komen ![]()