08-10-2021 09:55 AM
Hello all,
I have an setup that depending on certain values pulled from a database an array of DAQ Channel Constants is created, having in it only the channels associated with the data pulled. Most of these channels are going to be used strictly for Reading measurements but a few of them will be written to. Specifically there are two that will be sending a signal to regulators, but one of these two will not always be needed. I'm looking for a way to validate whether or not a channel constant is Null or empty (like "" in a string) depending on how LabView handles these.
A case statement does not work as the output tunnel requires a wire from each case so if the value does not exist in my array then I need to output SOMETHING instead of the specific channel. Right now I have an blank channel constant but (and here is the question) I know of no way to check if it is empty or populated and I don't want to be sending information via tasks to an empty channel (if LabView would even let that happen without an error).
Here are some images to help communicate my point:
If this is an incorrect or inefficient way to proceed, I'm always excited to learn ways to better program my LabView programs so any suggestions are welcome!
Please ask questions if I have not explained anything well enough.
Thank you!
Solved! Go to Solution.
08-10-2021 10:27 AM
You can use string functions (such as "Empty String/Path") to resolve the contents of a DAQmx Channel. You can similarly feed strings containing the same text into the DAQmx functions that expect DAQmx Channels.
This is one of the times you can safely ignore the coercion dot you'll see when you wire a DAQmx channel to a string input.
-Kevin P
08-10-2021 10:28 AM
Awesome! I was hoping this might be the case but was uncertain. I appreciate the answer!
08-10-2021 10:34 AM - edited 08-10-2021 10:35 AM
There are two ways to do this. The most direct way to do this is to just use the Equal? operator and check with an empty channel constant:
The second way is to use a Set instead of an Array, which handles this for you and you don't need comparisons or array searches or anything:
Edit: Dang, Kevin beat me to it, and I forgot about the Empty String? working here even though I'm 99% sure I've done it myself 🙂
08-10-2021 10:49 AM
This is a great answer too! I can't believe I overlooked simply comparing it to an empty constant!
08-10-2021 02:19 PM
And I liked the clever use of the new-ish Set datatype!
-Kevin P