LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem typecasting 2D SGL array

Solved!
Go to solution

Hi,

 

I'm experimenting with my code and encountered a problem in typecasting a 2D SGL array:

typecast-problem.png

What's wrong in here? Type of wire source and sink is same "2-D array of single"...

 

Btw. this is LV8.6.1.

One more comment: putting a FOR loop around the problematic "typecast" solves the problem - but the vi should also work without a FOR loop...

Message Edited by GerdW on 07-22-2009 02:58 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 1 of 6
(3,623 Views)

I don't think the Type Cast function accepts arrays with more than one dimension.

I've tried this in LV8.5 and LV7.1, and the behaviour is the same. I could only get it to accept one dimensional arrays.

 


@GerdW wrote:
Type of wire source and sink is same "2-D array of single"...

That may be true because Type Cast attempts to use the same input type as the wire source (2D array of scalars) and adapts its input node to the same type, but as it cannot accept them you get a broken wire.

 

Message Edited by Thoric on 07-22-2009 02:44 PM
Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 6
(3,605 Views)

Hi Thoric,

 

"I don't think the Type Cast function accepts arrays with more than one dimension."

 

Well after RTFM I can't agree with this, the context help clearly says: "x is the data you want to convert to type. x can be any data type."

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(3,598 Views)
When I removed the transpose array from the wire and connected a 2 d array constant directly, I got a different error. "You have connected to a polymorphic terminal that cannot accept this data type."
0 Kudos
Message 4 of 6
(3,587 Views)
Solution
Accepted by GerdW

Use "flatten to string" instead. It works just fine. (set "prepend ... size" to FALSE to get the desired functionality).

 

Typecasting multidimensional arrays is a bit dangerous, because the reverse operation cannot work. Typecasting a string to a 2D array is ambiguous (e.g. a string with 12 elements could be a 1x12, 2x6, 3x4, 4x3, 6x2, or 12x1 2D array). Typecasting a 2D array is thus forbidden, probably because the operation cannot be reversed with another typecast and a 2D array as type.

Message Edited by altenbach on 07-22-2009 09:41 AM
Message 5 of 6
(3,582 Views)

Hi Altenbach,

 

thanks for the good explanation.

 

I'm experimenting in creating a file format to log data, thus typecasting everything to string and save (append) that string to the measurement file. My next try will be to split the file operations in 3 steps (or maybe just two) to use polymorphism of the "binary write" function...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(3,565 Views)