LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nested If and else without case structure

Dear Norbert,

 

Give me some sample example.

 

I think we can use Statemachine without case structure. what you think?

http://www.ni.com/white-paper/7595/en/

 

BR,

Guru

Munna
0 Kudos
Message 11 of 45
(1,835 Views)

Hi Munna,

 

a state machine is essentially a Case structure inside a While loop.

 

How do you want that to run without the case structure???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 45
(1,833 Views)

Dear GerdW,

 

I think we can create statemachine also without case str. Please correct me if my undestanding is wrong.

 

BR,

Guru

 

 

Munna
0 Kudos
Message 13 of 45
(1,820 Views)

Hi Munna,

 

a state machine is more than just to decide what state to execute next!

 

As said before: in a case structure only the code in the current case is executed - in your (silly) approach all code is executed…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 45
(1,813 Views)

@Munna232 wrote:
[...]Please correct me if my undestanding is wrong.

 

BR,

Guru

 

 


Guru,

 

please stand corrected.

 

You are mistaken with your assumption, that case structure only "selects between return value options". Gerd already pointed out that you select for functions you execute or skip.

Your code has no chance of skipping code execution, so it will always execute all code. This will waste performance in the best case, in the worst case it will kill your whole computer, maybe even damaging peripherals.

 

Excluding specific pieces of code dynamically is an essential part of every programming language. Without that option, most of todays applications would not exist.

 

There is, on the other hand, a technique of implementing state machines without case structures:

Dynamic calling VIs using VI server.


This approach, however, is heavily convoluted, wastes performance at a great deal and is way more complex than case structures.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 15 of 45
(1,809 Views)

Dear Norbert,

 

Thank you so much for your valuable Information.

Yes, I will agree with you're point,

.................................................

Your code has no chance of skipping code execution, so it will always execute all code.

..................................................

 

Just I'm trying to get the information how much possibilities are  there with LabVIEW for these kind of approaches.

 

For you're information, In simulink we are not using Switch case. Instead of this we are using Multiport Switch (like Se
lector). We never faced any issues.

http://www.itu.dk/stud/speciale/segmentering/Matlab6p5/help/toolbox/simulink/slref/multiportswitch.h...

 

BR,

Guru

Munna
0 Kudos
Message 16 of 45
(1,804 Views)

Hi Munnam

 

how is Simulink coding related to writing LabVIEW VIs?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 45
(1,802 Views)

Guru,

 

Although it is possible to code using any imaginable approach, does not make it the "right way".  There is more to writing software than "making it work".  Heck, anyone, given enough time can write something that will execute.  Just as 1000 monkeys hitting a keyboard will write meaningful words...  But do the words or (if you can call them ) sentences make any sense?  Do they convey what the monkeys are thinking?  I doubt it.

 

Writing software needs to be done in a manner that when yourself or someone else reads that code in the future, or needs to scale or maintain the code, that it is possible to do so.

 

Often, when dealing with badly written code, it takes more time to decypher the actual intent, or to modify code which is not scalable; than to write the code from scratch.

 

 

0 Kudos
Message 18 of 45
(1,797 Views)

Please explain the reason behind the decision to avoid Case structures.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 19 of 45
(1,793 Views)

Dear GerdW,

 

I don't know relation b/w Simulink and LabVIEW VIs.Infact I don't know how they implemented simulink blocks in MATLAB.

Just we are using Slector kind of SW in Simulink block instead of Switch cases.

 

BR,

Guru

 

 

Munna
0 Kudos
Message 20 of 45
(1,790 Views)