LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a button with event structure to start and stop the same counting loop?

Solved!
Go to solution

How to use a button with event structure to start and stop the same counting loop inside the event?

 

0 Kudos
Message 1 of 7
(11,753 Views)

Show some code so we understand what you have.  But in general, you should not have loops inside your event cases.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(11,747 Views)

There really should never be any loops inside of events.

 

Other than that, it is impossible to answer your question because you haven't provided any code for us to look at to see what you are doing now.

0 Kudos
Message 3 of 7
(11,736 Views)

I guess I have made a mistake you mentioned.

ask.jpg

0 Kudos
Message 4 of 7
(11,734 Views)

I wonder why this simple idea cannot be implemented like in VB for example. Smiley Frustrated

0 Kudos
Message 5 of 7
(11,729 Views)
Solution
Accepted by topic author tomsze

First, you probably have Lock front Panel until event is complete set to True.  That means you can't hit the button again.  Without your actual VI, I can't tell for sure.  But the default setting for events is True, and whenever someone messes up event structures, that is a common cause.

 

Second, the value of the button comes into that loop as either True which means the loop only runs once, or comes in as False, which means the loop will run forever because the value on the wire isn't read again until the event structure is fired again, which may or may not happen based on the paragraph above.  These are basic LabVIEW dataflow principles.

 

This has nothing to do with VB.  I don't know how you'd think this would work in VB, but I guarantee that if you programmed it the same way VB, it wouldn't work there either.

 

Here is the equivalent code in a text language.

 

On Event BlankButton Value.Change

ButtonValue = BlankButton.Value
i=0
Do
      Print "Numeric = " & i
       i=i+1
Until ButtonValue=True
EndSub
//Notice how when Button Value = False, that loop will run forever
because you never update buttonvalue again!
Message 6 of 7
(11,721 Views)

Yes,it can do what I want now after I did not lock the panel for that button.

0 Kudos
Message 7 of 7
(11,616 Views)