From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

use the same command

Solved!
Go to solution

Without restructuring your code I can reduce the number of local variables by 3 and still give you the same functionality.

 

There is zero purpose to reading a control value, and then writing that value back to that same control.  And that is what you are doing.  You are also reading that controls value in two other locals, right next to the terminal.  Why do this when the data is right there available for you?  Local variables can make debugging difficult, and the number of them used should be kept to a minimum.  This doesn't mean "Never use local variables", this means "Use them when appropriate, but choose to read from the terminal first, and use locals only when the data isn't easily available on a wire."

 

Also if you want to get real fancy you should look into the event structure which can generate events as a control value changes, which can simplify code because you don't need to constantly poll values.

Message 11 of 16
(893 Views)

Can you give me an exemple using the event with my code please ?

0 Kudos
Message 12 of 16
(889 Views)

It'll look something like this:

EventStructSnippet.png

0 Kudos
Message 13 of 16
(868 Views)

Run the attached VI.  Entering Hi or Hello will turn on the LED for that value.  Notice the loop doesn't poll and only performs an action if the user closes the window, or changes the value in the string.  I also show an alternate way of doing the same check, using an array of strings to check.

 

In the future post code not pictures.  Pictures cannot be ran.

0 Kudos
Message 14 of 16
(863 Views)

Are you trying to verify a string "chaine" is a particular value?  If so, try using an Event structure with a Value Change event for the string value. Within the Value Change event, add a Case structure with the NewValue of the string as the input with multiple cases containing your valid string values.

 

0 Kudos
Message 15 of 16
(861 Views)

Ok thanks you very much for your example guys. I will try to adapt it for my IT application.

0 Kudos
Message 16 of 16
(839 Views)