LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with converting number within Case Structure

I need to convert a number into Unsigned Byte Integer, Unsigned Word Integer or Unsigned Long Integer by Case. I implementet it by creating a Case Structure with the cases "UNSIGNED8", "UNSIGNED16" and "UNSIGNED32" with the respective function in it, but the result in any case is the highest implementet function.

E.g.
I want a UNSIGNED8 and use the respective String to control my Case Structure. The result "outside" the Case Structure is an UNSIGNED32, the "highest" function within my Case Structure.

After removing the UNSIGNED32-Function, leaving UNSIGNED8 and UNSIGNED16, the result is UNSIGNED16.

Is this a bug or am i doing something wrong?

Thx in advance for any help 😉
0 Kudos
Message 1 of 5
(3,073 Views)
Hi Micha,

Could you possibly attach your vi? I'm not sure I understand your problem fully.

Nick
0 Kudos
Message 2 of 5
(3,073 Views)
It sounds like you are wiring them all through the same output tunnel from the case structure. The tunnel can only handle one type of data and will coerce to the type that will represent the most values. In your case you are feeding the tunnel several different types of unsigned intergers. They all get coerced to the "highest" type wired to the tunnel. That is correct functionality. You need to have a different tunnel for each data type.

Kelly Bersch
Anadigm - The FPAA Company
http://www.Anadigm.com
Message 3 of 5
(3,073 Views)
LV has to choose a format for the output tunnel, it will then coerce the others to that format. It's not a bug, it's a feature:-) - polymorphism in action...

The output must be intended somewhere, could you move that code into the different cases? Or flatten the data inside the cases (or convert to a variant), then send the string and type to where you need it?
Message 4 of 5
(3,073 Views)
Thx, this solution hit the point. I simply didn't see the wood for the trees - the number needed to be flattened to string before given to another function.

Now - after flattening the data within the case structure - the problem is gone.

Thank you very much 🙂
0 Kudos
Message 5 of 5
(3,073 Views)