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: 

Darren's Weekly Nugget 1/23/06

Once again, I'm posting two nuggets...but this time, it's because my first nugget only applies to LabVIEW 8.0 users, and I didn't want everybody else to feel left out:

Nugget 1: In case you didn't notice, there is a new function on the Comparison palette in LabVIEW 8.0 called "Empty Array?". You can wire an array of any datatype and any dimension to this function, and it returns a boolean indicating whether or not the array you wired in was empty. This is much more elegant than the way we always had to do it in the past, which was to use the Array Size function to check the size...it got even more annoying with an array of 2 or greater dimensions, since you had to multiply the elements of the Array Size output.

Nugget 2: Another function on the Comparison palette is "Empty String/Path?". But did you know this function can tell you about the emptiness of other things besides strings and paths? There are actually 5 different datatypes this function can check the emptiness of. In addition to strings and paths, you can also use this function to determine if a variant, picture, or DSC tag is empty. I have used this trick before on a subVI that had a variant input to it...I checked the variant on the diagram to see if it was empty, and if so, I assumed the user did not wire anything into that input of the subVI.

-D

Message 1 of 7
(12,862 Views)

Cool,

Is there a reason why the functionality of the two cannot be combined into one? Maybe I am overlooking something obvious...after all, it's monday morning.

Just make one tool called "Empty?" and do all of the above. 😮
 
The swiss army knife of emptyness! 😄
0 Kudos
Message 2 of 7
(12,835 Views)
Don't worry, it's on the list of "things to do" for a future LabVIEW version.  We'll have to make sure to support the situation where you have an array of things that could be empty (like an array of strings) and you want to check the emptiness of the elements vs. the emptiness of the array itself.
 
-D
Message 3 of 7
(12,823 Views)
Wow.  Didn't know empty string/path works for picture controls also.  This is very nice.  You learn more about your tools everyday!  Thanks.
0 Kudos
Message 4 of 7
(12,784 Views)

@rberger wrote:
Didn't know empty string/path works for picture controls also.

Most likely, the reason for this (and probably the DSC tag (and I/O channels, which can be coerced)) is that the picture control is actually a string describing how to build the picture (if you look inside the picture VIs you will see that they use string functions to build the picture).

___________________
Try to take over the world!
Message 5 of 7
(12,772 Views)
Nugget 1 is a very welcome improvement. We've implemented an Empty Array VI in OpenG Data Tools using a variant input but it has to flatten the whole array data to work (the size is stored in the header of a flattened array data). Thus it was inefficient for large arrays.


LabVIEW, C'est LabVIEW

0 Kudos
Message 6 of 7
(12,618 Views)


@Jean-Pierre Drolet wrote:
We've implemented an Empty Array VI in OpenG Data Tools using a variant input
I have always wondered why you did that instead of creating a polymorphic VI to account for all the common data types (at least of 1D and 2D arrays) using the Array Size>>>Multiply Array Elements route. That way, only the other arrays would default to the variant version and the execution would be faster. It's probably a moot point now, though, since no one will probably go back and rework it now that LV has a build in function.
 
BTW, I have been toying with the idea of making a polymorphic VI creator using scripting, which would be a great time saver, but haven't had any time to really make something of it, and without a clear future for scripting, I'm not sure how much time I would want to put into this (although it probably can be imported into newer versions). I don't suppose you would something like that for OpenG, would you?

___________________
Try to take over the world!
Message 7 of 7
(12,607 Views)