LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Executing Code with true/false input

Solved!
Go to solution

Ok so I must be over thinking on how to do this. I am trying to run a section of my code when I recieve a True value. When False I do not want it to do anything. Ive tried using a true/false case structure but the requirement to hook the false case to something is screwing me. Also tried a while loop but it just latches on and never reads the false after its already on. 

0 Kudos
Message 1 of 9
(3,341 Views)

@joedirt wrote:

Ok so I must be over thinking on how to do this. I am trying to run a section of my code when I recieve a True value. When False I do not want it to do anything. Ive tried using a true/false case structure but the requirement to hook the false case to something is screwing me. Also tried a while loop but it just latches on and never reads the false after its already on. 


"requirement to hook the false case to something".  What do you mean?  Post your code so we can see.  Do you have some wire that passes out of the case structure to some other code or to an indicator?

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 2 of 9
(3,336 Views)

I have data coming out of the case structure in the true case. but in the false case it requires that data point to be connected. And I dont want it to do anything. But I can't connect it to anything. and if I set it to default it doesn't work. Basically I only want that portion of the code to run when i get True, when False I dont want to write anything to the spreadsheet file. 

0 Kudos
Message 3 of 9
(3,328 Views)

Then place the file writing code also inside the case structure!

 

(btw, your code is completely silly. ou are building an array with one element, measuring the size as one, subtracting one, then getting the element at index zero. This is always the exact same value that entered he case structure a nanosecond earlier. You can delete all that code and only leave a wire and it would not make any difference.)

0 Kudos
Message 4 of 9
(3,318 Views)
TAKE those tutorials! If you don't want some code to execute, it belongs inside the case statement. Thats just common practice with all programming languages.
0 Kudos
Message 5 of 9
(3,314 Views)

Okay and I will check out tutorials. I just did all that silly code because I wanted to take the last element of the array and write it to the spreadsheet without adding other values, BUT at the same time enable it to append to file because Ill repeat this code over. 

0 Kudos
Message 6 of 9
(3,309 Views)
Solution
Accepted by topic author joedirt

@joedirt wrote:

Okay and I will check out tutorials. I just did all that silly code because I wanted to take the last element of the array and write it to the spreadsheet without adding other values, BUT at the same time enable it to append to file because Ill repeat this code over. 


You don't have an array until you make one right there out of a single element. There are no "other values". There is one element in the array, which is the first and the last element and exactly same as the value you used to build the array. Once you do the tutorials, you'll laught about your code. It is absolutely pointless.

0 Kudos
Message 7 of 9
(3,302 Views)

Guess I am just confused because if that true case is on for more than a few seconds, I get more than 1 value in my spreadsheet file. But it doesnt really matter either way for this application since its only gonna be on for <1second

0 Kudos
Message 8 of 9
(3,296 Views)

You get one row (time and value) whenever you append to the file, so it all depend on the loop rate. If some entries seem to have the same timestamp, your time resolution is not set high enough.

0 Kudos
Message 9 of 9
(3,287 Views)