LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darren's Weekly Nugget 11/20/2006



@Darren wrote:

The number of elements in the array that is wired to the Array to Cluster function is dynamic, i.e. it could be anything at run-time.  Since the elements in a cluster are a part of its data type, and LabVIEW is a strictly-typed language, LabVIEW cannot compile a VI that contains a cluster with an unknown number of elements.  Thus, you must statically define the number of elements in the generated cluster at edit time.

And yes, we are aware of the difficulties regarding functions with these "hidden" configuration options, and we're looking into ways of addressing this issue in a future LabVIEW version.

-D




The Array to Cluster node should, IMO, have an optional "type" input that allows setting the output cluster type and, therefore, size.  One of the most common patterns for using the Array to Cluster node is when one is iterating over the elements of a cluster, by first converting it to an array using the Cluster to Array node, which means that you have the original cluster type readily available.



In fact, this technique is possible with arbitrary clusters using the OpenG Variant tools (lvdata library): convert the cluster to an array of variants, iterate over the array, and convert the array of variants back into a cluster.

Message Edited by Jim Kring on 11-23-2006 10:20 AM

Message 11 of 21
(5,166 Views)
Jim,

You mean like this (actual code)



Shane.

Message Edited by shoneill on 11-24-2006 08:17 AM

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 12 of 21
(5,031 Views)
Hi all,
Just one thing I noticed about the "array to cluster" function, the maximum size that can be set is 256 but what surprised me is that 0 can be set Smiley Surprised but if 0 is set it will actually operate like if 1 was set...

Weird, no ?


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 13 of 21
(4,966 Views)
I just found this (with TiTou's help).
 
Associate text with a wire.
 
 
See this thread to learn how.
 
 
Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 14 of 21
(4,871 Views)
With my help Smiley Surprised

That's too much honor... Basically I said "you can't do this" and there you came with the trick.
Your hate of "you can't do this"-replies is the one to be honored 😉

I once read this sentence (don't remember who it is from) "We are not limited by the vast domain of the possible, but by the space inside us"



We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 15 of 21
(4,867 Views)

Love your come-back Shane. Smiley Very Happy

Since many of us are putting together the same constructs (cluster to array ...) so we can iterate through a cluster....

How would Y'all feel about adding the ability to directly index through a cluster on the edge of a For or While loop?

Is this a good idea or a bad one?

Your thoughts?

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 16 of 21
(4,869 Views)


@shoneill wrote:
Jim,

You mean like this (actual code)



Shane.

Message Edited by shoneill on 11-24-2006 08:17 AM



Hi Shane,

The Type Cast function is a good solution for clusters of fixed-width clusters (i.e., brown-wired clusters), with elements of numerics, booleans, etc.  However, it won't work on variable-widthed clusters (i.e., pink-wired clusters), with elements of strings, arrays, etc.



Cheers,

Message Edited by Jim Kring on 11-24-2006 12:10 PM

Message 17 of 21
(4,823 Views)
The Cluster-to-Array function itself won't accept the cluster containing the variable-length data-types (arrays).

Message Edited by pauldavey on 11-27-2006 05:23 PM

0 Kudos
Message 18 of 21
(4,368 Views)
The Cluster-to-array function may not take clusters of arrays, but it DOES take clusters of strings, which are variable length.

I find the inability of LV to accept a cluster of strings as datatype (For the Type cast function) a limitation which should be corrected.

Is there a reason wha this shouldn't work?  LV doesn't use terminated stringa AFAIK, but shouldn't it be possible to work out how long the string is from the flattened data (1st 4 Bytes = String length)?

Shane.

Message Edited by shoneill on 11-27-2006 01:04 PM

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 19 of 21
(4,354 Views)
Just a quick note: I was in on a couple prior discussions about converting cluster-to-array, performing array-based processing, then converting array-to-cluster again.  The first one is here.  The second one got a "blue bar" response from someone internal to NI.   That one's here.  Not sure I'm adding much to this thread here so I'll be going now...
 
-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 20 of 21
(4,272 Views)