LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get my numerical inputs to reset back to 0 once the while loop has finished

I have a basic VI that generates random numbers between 0-10. the user must correctly guess the 4 numbers in a sequence. This all takes place inside a while loop and once the user guesses the correct sequence the game stops. The user must then click the start game again button. However the numerical inputs remain in the same position from the previous game. How do i set it up so that they reset to 0 when the new game begins.

 

cheers

0 Kudos
Message 1 of 7
(9,201 Views)

You can either:

  • Simply use a local variable to set the values of the controls to 0. Note: be sure to watch for race conditions!
  • Use the Reinitialize to Default method (using an Invoke node) for each control to reinitialize it.
Message Edited by smercurio_fc on 01-08-2010 02:59 PM
Message 2 of 7
(9,196 Views)
I made the current value default = 0 I then set reinitialize to default. Ran the VI but once it stoped and i clicked for go again the numbers did not revert to 0.
0 Kudos
Message 3 of 7
(9,179 Views)

Did you do either of the two things S-mercurio listed in his message?

Message 4 of 7
(9,177 Views)

Obviously not, you'll have to excuse me but im not the greatest with this software so some termanologies im not to sure on. What I did was right click the numerical input in the front panel and selected; data operations_make current value default and then data operations_reinitialize to default.

 

Its totally a user error on my part, just want some extra credit with this assignment.

 

Cheers

0 Kudos
Message 5 of 7
(9,164 Views)
That will simply do it one time, and is an edit-mode operation. If you want to do it at run-time then you need to it at run-time. If you want to use the invoke node method then for each control right-click and select Create -> Invoke Node -> Reinitialize to Default. See attached example.
Message 6 of 7
(9,142 Views)

Hey Guys,

 

Building on the excellent advice given by , if you need to reinitise a control back to its default value at the start of your application (i.e. when you hit the run button), use data flow to ensure the execution order of your block diagram. Below you can see a simple screencap, which shows how to use the error cluster of the invoke node to make sure the "reinitialise method" is called before the main body of the code.

 

 DataFlowing.jpg

 

Hope this has been useful.

Ta Ta,

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 7 of 7
(9,080 Views)