LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nested If and else without case structure

If you absolutely, positively have to do this the most inefficient way, you can do what your VI did - daisychain Select functions from the Comparison palette. It has every one of the disadvantages every one else has listed above. But it will work. So it is 100% possible.

 

Oh, and you have to convert your case selection criteria to one which a T/F selection can handle like you did, because the input is Boolean.

 

Otherwise, if you just want to be aware of what choosing other selections will do, you could use a case structure anyway, copy it for every case possible (but disconnected from your working VI), and put the whole set of copies inside a Disabled structure so it won't run but will be visible (sort of). Or you could print out the block diagram on paper. That will give you a picture for every potential case.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 31 of 45
(1,283 Views)

@jcarmody wrote:
[..]  I'd recommend against using LabVIEW with that kind of a request.

I'd recommend against using ANY programming language with that kind of a request.

 

That request might work in scripting environments with small "applications", but is an absolute no-go for anything else....

 

Norbert

 

PS: Just wondering, but April, 1st is still a bit away.....

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

Dear Jim,

 

It's our requirement means client requested like this. So, I'm getting the information like how many possibilities are there in LabVIEW.

 

So as I understood, it's quite difficult in LabVIEW without case structure in all the cases. (Like memory and execution speed).

 

My question is easy for text based programming languages (like said).

 

Thank you so much for your support and Help.

 

BR,

Munna

Munna
0 Kudos
Message 33 of 45
(1,266 Views)

@Munna232 wrote:

Dear Jim,

 

It's our requirement means client requested like this. So, I'm getting the information like how many possibilities are there in LabVIEW.

 


I think what people here are trying to say is:  your customer is wrong. Very wrong. You should not build your program like this, and it is part of your job as the expert to convince the customer to change his requirements.

 

Even text based languages don't really do this for larger projects.  Think of C.  One of the powerful aspects of C is that you can break the code in to different files and then build a project from these individual components.  When a programmer calls a function in a separate C file, someone doesn't have immediate access to the code. They have to go open up the other file, find the referenced function and read what it does. 

0 Kudos
Message 34 of 45
(1,259 Views)

Dear BowenM,

 

Thank you so much for your suggestion.

 

and your right

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

Still an aweful way to do it, but it will meet your requirements

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

 

I think that's one better solutions till now I got even though using case str for each case. Lets see this idea will work/not Beacuse here each case will give one result but finally we need only one result from all cases. 

 

BR,

Munna

Munna
0 Kudos
Message 35 of 45
(1,255 Views)
If it's just a request and you don't have a contract, just tell them the request is unreasonable. The customer is obviously not at all familiar with LabVIEW.
0 Kudos
Message 36 of 45
(1,251 Views)

Sometimes part of our job is educating our Customers, Bosses and co-workers on LabVIEW

 

By definition, a If Then/Else structure in LabVIEW is a Boolean Case Structure.

 

If you where writing your code in C would you be able to

 

If X Then

{

    If Y Then

                {

               

                }

     Else

                {

 

                }

}

 

Else

{

     If Y Then

                {

               

                }

     Else

                {

 

                }

}

 

This is the EXACT equivalent in LabVIEW

If Then Else.png

 

You need to enlighten your customers.

 

As been pointed out above, without using case structure, all 100% of your code will run.

What if you were controlling a motor?

 

If X Then {run forward} Else {run reverse}.

 

 

Without a Case Structure, both the motor forward code and motor reverse code would run. What would the motor do? 

Omar
0 Kudos
Message 37 of 45
(1,209 Views)

It occurred to me that somebody doesn't want LabVIEW used on this project.  I hope the same criterion is used when evaluating their favored language, perhaps: "All the code needs to fit on one screen so we can see everything without scrolling."  ...or, something equally absurd.

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 38 of 45
(1,190 Views)

Dear Omar,

 

Thaks for your reply.

 

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

What if you were controlling a motor?

 

If X Then {run forward} Else {run reverse}.

 

 

Without a Case Structure, both the motor forward code and motor reverse code would run. What would the motor do?

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

 

what about this idea?

 

 

BR,

Munna


.

Munna
0 Kudos
Message 39 of 45
(1,186 Views)

Could it be your customer is confusing the case structure with the stacked sequence structure?

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 40 of 45
(1,177 Views)