LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview 2015 strange error with type def. enum and case structure

Very interesting bug. 

I created type def. from enum and connect it to case.

And the cases do not work properly.

If I disconnect from type def. all work correctly.

Download All
0 Kudos
Message 1 of 8
(2,614 Views)

What behavior are you seeing? It seems to be working for me as I would expect.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 8
(2,577 Views)

@MaxEngee wrote:

Very interesting bug. 

I created type def. from enum and connect it to case.

And the cases do not work properly.

If I disconnect from type def. all work correctly.


I agree with Matt -- it works "exactly as you told it to work".  I notice you have a TypeDef, yet are creating two additional representations, a Numeric and a Message to represent the same thing, and maybe this is where you are getting confused.

 

Your TypeDef has three values:  Get Settings, Get Data, and Close Subpanel.  You might (logically) think they should be ordered that way, i.e. Get Settings would be (numerically) "first", and Close Subpanel would be "last".  As you have defined your Enum, however, the order is backward, but so what?  You can either ignore the numerics or change the order in the TypeDef by editing it and moving entries up and down as needed.

 

Here's a small variant on your "LabVIEW Error" VI that "takes advantage" of the backward ordering of your Enum and shows how to "step through" the values one at a time in a While loop, output the Enum Name (e.g. "Get Data"), the Enum Value (2, in the case of "Get Data"), and echo the value of the Enum itself by simply creating an Indicator ("Menu Ring") for it. 

 

Note all of the "common code" takes place outside the Case Statement.  I deliberately removed the "Default" value, which is not needed as all of the Enum possibilities are enumerated in the Case labels.  This can help you prevent a bug if you add another "choice" to the Enum (e.g. "Process Data") -- once you change the Enum, your Case Statement will "break" until you add the newly-created Case to it.  If you still had "Default" as a Case Label, when you said "Process Data", you'd repeat whatever Case was labelled "Default", probably not what you wanted.

LabVIEW Reverse Enum.png

Bob Schor

 

Download All
0 Kudos
Message 3 of 8
(2,552 Views)

Look at my example carefully.

The "default case" is executed instead "get data"

0 Kudos
Message 4 of 8
(2,532 Views)

I was able to recreate your issue. The trick is opening the file in LV15 so that no recompile is needed.

It looks like your case structure is corrupt. Anything that causes a recompile will make it work.

Disconnecting from the Type Definition provides a different (although equal) data type to the case structure

which makes it recompile.

 

Did you notice if it works with the Type Definition once you have run the vi with the "Untyped" enum?

It does for me. Also replacing the Type Definition with the version from disk works.

 

The question is why is the case structure corrupt?

Did you enter the case names by typing them or did you let LabVIEW do it for you?

 

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 8
(2,524 Views)

@MaxEngee wrote:

Look at my example carefully.

The "default case" is executed instead "get data"


Not when I run your VI.

It works just fine.

 

EDIT:  Reading Bob's post now, I see that it works for me because I opened it in LV 2017.

0 Kudos
Message 6 of 8
(2,515 Views)

An official response came from the technical support service.

This is a bug. It is fixed in LV 2016

0 Kudos
Message 7 of 8
(2,488 Views)

Can you post a CAR here so that we can try to get it patched into 2015?

0 Kudos
Message 8 of 8
(2,480 Views)