07-22-2009 07:54 AM - edited 07-22-2009 07:58 AM
Hi,
I'm experimenting with my code and encountered a problem in typecasting a 2D SGL array:
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...
Solved! Go to Solution.
07-22-2009 08:42 AM - edited 07-22-2009 08:44 AM
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.
07-22-2009 09:08 AM
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."
07-22-2009 11:20 AM
07-22-2009 11:41 AM - edited 07-22-2009 11:41 AM
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.
07-22-2009 02:44 PM
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...