LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

switching from case to event structure

I once down converted some LV 7.0 code to 6.0 and it (automatically) converted an event structure to a case structure.  When trying to upgrade some code to change a case structure to an event structure, I didn't see any means for doing that (a flat sequence, yes... event structure, no).

Is there a way to convert a case to an event structure -- if not, why not?

   ...Dan
0 Kudos
Message 1 of 7
(3,218 Views)
Because the case structure and the event structure are two fundamentally different objects. The only real common thing between them is that they're rectangular and have a selector. Think about it: Let's say you have a case structure that's driven by a Boolean that's determined programmatically, such as whether some value is larger than another. How do you convert this to an event structure? What event do you tie the "False" part to, and what event do you tie the "True" part to?
0 Kudos
Message 2 of 7
(3,209 Views)
No, the question is very valid! 🙂
 
The resulting code does not need to make sense immediately, but I have desired this functionality (=convert case structure to event structure) at several occasions. I have many legacy programs that were made before the introduction of the event structure. Some contain big case structures with many cases, one is the "idle" case which only contains a small wait statement, while others are executed if certain controls change their value. (Sort of a poor man's event structure emulation ;)). Upgrading this old code would require a simple replacement of the case structure with an event structure so each event case contains the code of one of the original cases, followed by a quick manual cleanup (assignment of the event triggers, etc.).
 
Without such a conversion tool, my code upgrade is major work, especially if there are many cases and dozens of shift registers crossing the case structure. Basically, I need to rebuild things from scratch.
 
Summary: It would be useful to be able to easily convert between event structure and case structure and vice versa using a "replace" command. I even remember asking for this functionality. 🙂 I would use it!
Message 3 of 7
(3,205 Views)
smercurio_fc;

You say there is nothing in common, yet go ahead and downconvert an event structure and see what you get -- it'll be a case structure, that's what.  For that matter, what does a case structure and a flat sequence have in common?  LV allows us to switch between those two.

altenbach expands very nicely on my post/request, thanks.

   ...Dan
0 Kudos
Message 4 of 7
(3,197 Views)
Additional note: Right now, we can for example convert a case structure to a "stacked sequence", which seems much more useless than the above request.
  1. Case and event structures are quite similar. We have a stack of code segments and one is selected to execute if certain conditions are met.
  2. Case structures are very fundamentally different to stacked sequences and I have a hard time imagining a scenario where on would want to convert between the two. After a bit of thinking, it could be useful to convert from a stacked sequence to a case structure, for example when trying to shift the code towards a state machine architecture, but we cannot do that! 😮 We can only convert from a case structure to a sequence... 😞

 

EDIT: Just saw your above comment after writing this post. I see you are puzzled about the case->sequence conversion too. 😉

Message Edited by altenbach on 04-04-2006 10:12 AM

Message 5 of 7
(3,188 Views)
Yes, it gets converted it to a case structure, but that's probably LabVIEW saying "well, I don't have this structure available, and the case structure is the closest thing, so I'll use that".

What does a case structure and a sequence frame have in common? I have no idea, and I never understood why the ability to switch between these two was made available. altenbach gives one possible scenario, but that's not even available. Frankly, if given the choice between switching from a case structure to a sequence frame as opposed to an event structure, clearly the event structure is the better choice.

Your original question was why there's no automatic way of converting from a case structure to an event structure, and I provided a reasonable argument as to why there isn't. Instead of taking it out on me, based on your response's wording and bolded text, and message rating given (I am assuming it was your rating - if not I apologize) please take it out on the LabVIEW developers.
Message 6 of 7
(3,183 Views)
smercurio…

Sorry, the BOLD was an accident, I'll blame that on this web client.  I normally never use bold but had pasted from the forum and it just happened.

The rating was neutral, no slight intended.  Thanks for your response, the rating system is almost redundant since anyone taking time and effort to respond should receive a good rating.  I figured the 5 stars goes to anyone who really learns me something good!  (grammatical error intentional)

   ...Dan

Message Edited by dgholstein on 04-04-2006 12:28 PM

0 Kudos
Message 7 of 7
(3,178 Views)