LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In Dynamic Menu Insertion the case structure in the while loop, shows always default case.I don't like it

I've modified a VI that is Dynamic Insert Demo (examples). When VI runs, Front panel shows default case. Choosing another item it appears for few seconds ad after appears default case item. Why can i remove default case in case structure?
0 Kudos
Message 1 of 5
(2,832 Views)
den:

Default case processing is REQUIRED in ANY language that processes
case structures whether it is LabVIEW, Fortran, Basic, C or any other
language you ever heard of.

Think about it logically, a case structure is a elementary branching
operation. The computer has come to a fork in the road, it has to
make up it's mind what to do next. It has either to go left or go
right. It HAS to do one or the other.

If all the cases aren't covered and the computer gets case data that
isn't covered by the programmer enumerated cases, THEN WHAT DOES IT
DO? QUIT? It HAS to know what it is going to do next with unexpected
data. Computers (at least in in the non-AI world), unlike people,
don't improvise solutions to unexpected situations on their own, they
can only follow their program written the programmer (you).

With simple true-false cases we don't think about this much because
the sum of the true and false cases comprises ALL the possible cases
which can exist for a boolean case structure, so there are no
unexpected data cases and thus there is no need for a separate
"default" case in this one special circumstance. With all other data
types (strings, numbers, etc.) there are an infinite number of
possible cases.

Create a boolean case structure and try to remove the false case (or
the true case). You can't do that for the same reason that you can't
remove the default case for other data types without getting an error.
It leaves the computer in a situation where the computer doesn't know
what to do for some possible results.

The If or If-then-else structures that many people use are just
boolean case structures where either the false case is implicit (if
then with no else block version) and nothing is done for the false
calse, or false is explicitly defined in the else block.

So you see then, there ALWAYS has to be a default case to cover
catch-all situations not emumerated by the programmer for these
non-Boolean data types.

You usually don't have to do ANYTHING in the default case. It just
has to exist. Some people may use it to report an error back to the
user like "Unexpected data encountered" or something similar.

Do you remember the pop song "Did You Ever Have To Make Up Your Mind"
? "You better go home son and make up your mind..."

Douglas De Clue
LabVIEW programmer
ddeclue@bellsouth.net

den wrote in message news:<50650000000800000067520000-1023576873000@exchange.ni.com>...
> In Dynamic Menu Insertion the case structure in the while loop, shows
> always default case.I don't like it
>
> I've modified a VI that is Dynamic Insert Demo (examples). When VI
> runs, Front panel shows default case. Choosing another item it appears
> for few seconds ad after appears default case item. Why can i remove
> default case in case structure?
0 Kudos
Message 2 of 5
(2,832 Views)
den:

Default case processing is REQUIRED in ANY language that processes
case structures whether it is LabVIEW, Fortran, Basic, C or any other
language you ever heard of.

Think about it logically, a case structure is a elementary branching
operation. The computer has come to a fork in the road, it has to
make up it's mind what to do next. It has either to go left or go
right. It HAS to do one or the other.

If all the cases aren't covered and the computer gets case data that
isn't covered by the programmer enumerated cases, THEN WHAT DOES IT
DO? QUIT? It HAS to know what it is going to do next with unexpected
data. Computers (at least in in the non-AI world), unlike people,
don't improvise solutions to unexpected situations on their own, they
can only follow their program written the programmer (you).

With simple true-false cases we don't think about this much because
the sum of the true and false cases comprises ALL the possible cases
which can exist for a boolean case structure, so there are no
unexpected data cases and thus there is no need for a separate
"default" case in this one special circumstance. With all other data
types (strings, numbers, etc.) there are an infinite number of
possible cases.

Create a boolean case structure and try to remove the false case (or
the true case). You can't do that for the same reason that you can't
remove the default case for other data types without getting an error.
It leaves the computer in a situation where the computer doesn't know
what to do for some possible results.

The If or If-then-else structures that many people use are just
boolean case structures where either the false case is implicit (if
then with no else block version) and nothing is done for the false
calse, or false is explicitly defined in the else block.

So you see then, there ALWAYS has to be a default case to cover
catch-all situations not emumerated by the programmer for these
non-Boolean data types.

You usually don't have to do ANYTHING in the default case. It just
has to exist. Some people may use it to report an error back to the
user like "Unexpected data encountered" or something similar.

Do you remember the pop song "Did You Ever Have To Make Up Your Mind"
? "You better go home son and make up your mind..."

Douglas De Clue
LabVIEW programmer
ddeclue@bellsouth.net

den wrote in message news:<50650000000800000067520000-1023576873000@exchange.ni.com>...
> In Dynamic Menu Insertion the case structure in the while loop, shows
> always default case.I don't like it
>
> I've modified a VI that is Dynamic Insert Demo (examples). When VI
> runs, Front panel shows default case. Choosing another item it appears
> for few seconds ad after appears default case item. Why can i remove
> default case in case structure?
0 Kudos
Message 3 of 5
(2,832 Views)
Actually, a default case is NOT required for all situations.

However; this may be one of those situations where you must have a default case.

I don't know what sample you are talking about. If you could give the exact name, and also the location (what sub menu in the examples it is located), we may be able to better answer your question.

Since I don't know what you are trying to do, I can only offer the following as a guess:

Try using a shift register to store the previous selection. When the selection is made, and the case is chosen, you can pull this previous selection out of the shift register and set the current case to that value.

If you look at the Programming Designs.. Discussion Topic, you will find some program designs that includ
e state machines. The state machine I posted has an example of using a single shift register to store all data using a cluster. This makes it scaleable. I would suggest that this may be something you should consider. However; again, I don't have your code, so I can't tell what your problem is.
0 Kudos
Message 4 of 5
(2,832 Views)
I finally figured out what example you were talking about, and I think I know what you meant by the case problem.

This is a string input to a case. Absolutely positively you must have a default when iputting a string to a case, otherwise the structure doesn't know what to do.

I don't know what you are trying to do in getting rid of the default case. If you could elaborate on that, we may be able to offer some assistance.
0 Kudos
Message 5 of 5
(2,832 Views)