LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Run Button to VI

Let's say i'm making any program-calculator,game or any... I want to add a start button or on button inside the VI instead of pressing the white arrow above the VI. How can I do that?
T. A.
0 Kudos
Message 1 of 14
(23,910 Views)

You don't!

 

Simply configure the Vi to run when openend.

 

Write it as a event driven state machine that always runs and closes when you're done.

 

(Users of your program should not need to learn LabVIEW specific procedures such as operating the toolbar. Hide it during runs!)

Message 2 of 14
(23,909 Views)

Well maybe i didnt make myself clear 🙂 i WANT to add a start new game button, within the VI

T. A.
0 Kudos
Message 3 of 14
(23,906 Views)

That's just a state change in a state machine. No need to re-run the program. Make sure the VI does not stop when the game is over, but enter a "game over" state, for example. 😉

 

Message 4 of 14
(23,903 Views)

Don't get me wrong, you can do this in LabVIEW, but it's silly. There is no need for it.

 

Have a look at the attached code (LV 8.5) that I wrote quite a while ago to demonstrate the idea. Unzip all into one folder, open autostart.vi, and click the button on the front panel. It is just a quick draft and would need significantly more work to be even generally useable.

 

 


from the readme:

 

This is a silly little example that shows how one could use an Xcontrol to run a VI via a front panel button.

Make sure everything is inside the same folder, then open autostart.vi in LabVIEW.

Pressing the button on the FP runs the VI.


 

 

Message Edited by altenbach on 11-21-2009 11:38 AM
Download All
Message 5 of 14
(23,893 Views)

OMG!! are serious, isn't there a simpler code????????? Do you need all these sub VIs?? BTW, i wish u cld help me in this, how can i keep the value in the string indicator WITH releasing the 4 buttons. As in, i have 4 buttons, if i press one of them, it keeps pressed and the value remains indicated, if the button is released, the value disappears.

Please see the VI if you have time.

T. A.
0 Kudos
Message 6 of 14
(23,878 Views)

I don't see a string indicator....

 

Try changing the mechanical action of the buttons to "switch until released", maybe?

Message Edited by altenbach on 11-21-2009 12:21 PM
0 Kudos
Message 7 of 14
(23,875 Views)
Darn, i meant numeric indicator, u see when u add convert array to number, it gave me 1 for up, 2 for dow, 4 for left and 8 for right... how can i fix these values?? :S:S and NO i tried that one
T. A.
0 Kudos
Message 8 of 14
(23,870 Views)

rebghb wrote:
Darn, i meant numeric indicator, u see when u add convert array to number, it gave me 1 for up, 2 for dow, 4 for left and 8 for right... how can i fix these values??

Values 1, 2, 4, 8 are not broken. So why do you want to "fix" them?

(There are 16 possible combinations if you allow multiple buttons to be true).

 

Alternatives:

 

  • You could number the cases 1, 2, 4, 8.
  • You could use "search array", looking for TRUE and use the index output of the found element (-1 is all false).
Message Edited by altenbach on 11-21-2009 12:36 PM
Message 9 of 14
(23,867 Views)

Ahh, maybe you want the numeric indicator continue to display the last action....

 

--> Use an event structure and update the value only if one of the buttons goes ON.

Message 10 of 14
(23,849 Views)