LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Increment Value On button Click

Solved!
Go to solution

Hi all,

Can you help me?I want to increment one value whenever the Ok Button is clicked.On the same time i want to generate a random table with values when click on this Button.I want to increment values before Stop button is clicked, but now, all i have is a button Ok which increment one value and a button Stop who generate table.

Thanks in advice.

Download All
0 Kudos
Message 1 of 14
(6,243 Views)

Try placing the for loops inside the event case.

 

Think dataflow!

Message 2 of 14
(6,230 Views)

@altenbach wrote:

Try placing the for loops inside the event case.

 

Think dataflow!


Or, even better try out the Producer-Consumer (Events) template from File>>New...

Capture.png


"Should be" isn't "Is" -Jay
Message 3 of 14
(6,213 Views)

And wire the shift register through all event case (right now you're using use default if unwired). Or use a feedback node.

 

Ben64

Message 4 of 14
(6,198 Views)

@ben64 wrote:

And wire the shift register through all event case (right now you're using use default if unwired).

 


If the only other event is the stop event, it does not really matter since the final value is not used anywhere. However, the numeric indicator (should be blue!) belongs before the event structure so it correctly resets when the program is started and no button has been pressed yet.

Message 5 of 14
(6,170 Views)

@altenbach wrote:

@ben64 wrote:

And wire the shift register through all event case (right now you're using use default if unwired).

 


If the only other event is the stop event, it does not really matter since the final value is not used anywhere. However, the numeric indicator (should be blue!) belongs before the event structure so it correctly resets when the program is started and no button has been pressed yet.


We can't tell if the terminal is wired.  It may be that the value is meant to be retained on a "User Abort" case where only the stop button is pressed.

 

I doubt that that is the case but, without a specification I can't tell if it is desired behavior or a bug.


"Should be" isn't "Is" -Jay
Message 6 of 14
(6,152 Views)

This is my code.I tried to put for loops but i don't know how to set N iterations and how to connect.

0 Kudos
Message 7 of 14
(6,137 Views)
  • As we said, the FOR loops belong inside the button event.
  • Make the table an indicator, no need for local variables.
  • You can combine the two FOR loops into one.
  • The stop terminal belongs inside the stop event
  • The start button does not need to be connected to anything.
  • The numeric indicator should be before the event structure
  • What exactly do you want to show in the table?

 

Message 8 of 14
(6,093 Views)

In table i need to fill first column with number from 1 to 8 .I need 3 column with random numbers.In last column, on each row( because don't know other option) i want to put the number of times i clicked start button(i try to make an unique id for each generated table).Thanks a lot.

0 Kudos
Message 9 of 14
(6,089 Views)
Solution
Accepted by topic author Claudinho18

@Claudinho18 wrote:

In table i need to fill first column with number from 1 to 8 .I need 3 column with random numbers.In last column, on each row( because don't know other option) i want to put the number of times i clicked start button(i try to make an unique id for each generated table).Thanks a lot.


What is an ID for a table and where do you want to show it? Where do you want to put the number of times? Do you want to incrementally build the table, one added row for each button click?

 

See if this gives you some ideas. To incrementally build the table, put it in a shift register and append a new row. remove the FOR loop.

Message 10 of 14
(6,080 Views)