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: 

Need way to return false if a value hasn't been written yet.

Solved!
Go to solution

I'm a new labVIEW user here looking for a way to return false if the value hasn't been written yet.

I'm trying to use the 'select' tool to swap between values fairly early in my simulation. However, it requires data that hasn't happened yet, so I need something that waits for the value to be written.

Is there a way to use a while loop to wait until either TRUE or FALSE (instead of NULL) has been written, and then change in resonse?

0 Kudos
Message 1 of 7
(2,324 Views)

Your description is not clear. Are you talking about writing data to a device or a DAQ card? Please explain a bit more about your situation and also attach the code if possible.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 7
(2,322 Views)

Actually, that's the way dataflow works. A node (in this case the selector) won't execute until it's input have received data from whatever was before them.

 

Perhaps if you posted a bit of code showing what you are trying to do?

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 7
(2,318 Views)
Solution
Accepted by topic author EricLeafericson

All instances of data in LabVIEW (controls, terminals, constants, shift registers etc.) have a value, there is no concept of NULL.

A boolean control, before you write to it, will have it's default value (probably false). A string will be empty (but not NULL, it's still valid data). A numeric will be zero, a reference will be invalid (possibly equivalent to NULL, but that terminology isn't used.

 

Can you describe your requirement in more detail, I don't fully understand what you are needing to do.

 

If you want to wait for a value change (a boolean to change to true), then poll (repeatedly read) from the control terminal in a while loop with it wired directly to the condiitional terminal. It's default value of False will cause the while loop to continually loop until the value is set to True. I'd advise inserting a short Wait inside the loop to prevent it from hoggig a CPU.

 

 

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 4 of 7
(2,316 Views)

No, there's no external hardware yet. I'm saying the wires form a cycle. Here's the actual error message:

"These wires form a cycle, making two parts of the diagram interdependent, so each must wait for an input from the other and neither can execute."

I'm trying to get around that creating somethign that can make the Select tool default to "false" until the value is read into it. Perhaps some clever way to use while loops and boolean constants to wait until it recieves data from later in the simulation.

0 Kudos
Message 5 of 7
(2,314 Views)

I can't post any code for privacy reasons. Give me a minute to make the same error happen again using something similar.

0 Kudos
Message 6 of 7
(2,311 Views)

Solved! Thank you for your help. I kind of answered my own question suggesting while loops in the first place 😛

0 Kudos
Message 7 of 7
(2,293 Views)