LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

typecast issue

Solved!
Go to solution

In the excerpt VI I've attached, I have two questions.  (1) Why is the data pipe of the two clusters different (brown/pink), and (2) why can't I typecast into the VXI_Data type?

Download All
0 Kudos
Message 1 of 4
(2,277 Views)
Solution
Accepted by topic author mrbean

The brown wire means the cluster has a defined size.  All the elements in it are of a known size.  The pink wire means that the cluster size is not known.  Because a string can have a variable length (also arrays), there is no way to know the size of the cluster.  This is probably why the second instance can't be used in a typecast.

 

What are you really trying to do?  Perhaps you could flatten your data to a string and then unflatten it from a string.

Message 2 of 4
(2,273 Views)

ok, I thought the flattenToString was going to do the trick, But the code bombs at runtime.

 

0 Kudos
Message 3 of 4
(2,260 Views)

What do you mean by "bombs at runtime"?  Do you get a specific error message?

 

You are actually using Variant to Sring rather than Unflatten from String as I said.  Although, I'm not going to guarantee that Unflatten from string is the best way you should be doing this.

 

First, are you sure your byte array is long enough?  In your earlier VI, you were working with a 3 byte string and trying to create two arrays out of that at indices well beyond the end of your data.

 

Why not break your byte array down further and directly convert two bytes to your U16, and then the rest of the data to a string using byte array to string.  Then bundle those two results together into a cluster?

 

 

0 Kudos
Message 4 of 4
(2,257 Views)