LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why wont typecast allow me to concatenate?

Solved!
Go to solution

 

typecastCantConcatenate.png

 

As in the above snippet, I am not allowed to contatenate the output from a type cast. Why?

 

I was hoping to end up with a string of length (ROWS*COLS)*64/8, because each element is a 64-bit double, and every 8 bits will be interpreted as an ASCII character. Or am I understanding something wrong?

0 Kudos
Message 1 of 10
(954 Views)

Hi doug,

 

because you cannot concatenate strings at all using loop tunnels…

 

Simple fix (using ConcatenateStrings):

check.png

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 10
(933 Views)

this surely has something to do with how memory is allocated.

a string is a consecutive block of memory.

if you want to resize (add to) a string, new memory has to be allocated for the whole resulting string and the old part copied into it.

since this is very inefficient, i presume that labview prevents you from doing that.

 

use gerd's way to circumvent.

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 3 of 10
(915 Views)
Solution
Accepted by topic author dougbockILT

@dougbockILT wrote:

 

I was hoping to end up with a string of length (ROWS*COLS)*64/8, because each element is a 64-bit double, and every 8 bits will be interpreted as an ASCII character. Or am I understanding something wrong?


(First of all, you don't need the inner loop. You can cast a 1D DBL array directly.)

 

Second, all you probably need is a flatten to string without size information prepended, right?

 

FlattenIt.png


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 4 of 10
(907 Views)

My problem is that I want to convert the 2D Array to an ASCII string.
So for the following 2-by-2 array of doubles:

IN DECIMAL

15.458 0.123
5.007 6.540

 

 

 

IN BINARY

0100000000101110111010100111111011111001110110110010001011010001 0011111110111111011111001110110110010001011010000111001010110000
0100000000010100000001110010101100000010000011000100100110111010 0100000000011010001010001111010111000010100011110101110000101001

 

 

concatenated column by column, row by row:

0100000000101110111010100111111011111001110110110010001011010001001111111011111101111100111011011001000101101000011100101011000001000000000101000000011100101011000000100000110001001001101110100100000000011010001010001111010111000010100011110101110000101001

 

interpreted as ASCII string:

 

@.ê~ùÛ"Ñ?¿|í‘hr°@+ Iº@(õ\)

 

which has length 32, as expected.

 

 

0 Kudos
Message 5 of 10
(897 Views)

(posting by phone, cannot test).

 

My code should do that. Have you tried?

If you want to do by columns, transpose the 2D array first.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 6 of 10
(889 Views)

@altenbach wrote:

(posting by phone, cannot test).

 

My code should do that. Have you tried?

If you want to do by columns, transpose the 2D array first.


Works, however I am not getting the same output as expected (done on this website) ... I'll trust LabVIEW on that.

flatten2dArrayToString.pngflatten2dArrayToStringScreenshot.png

Many thanks!

0 Kudos
Message 7 of 10
(874 Views)

try right click on the string indicator and choose "Hex Display" perhaps this more helpful to compare.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 8 of 10
(869 Views)

Hi doug,

 

that website only accepts ASCII text, but no DBL float numbers…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 9 of 10
(866 Views)

Thanks Gerd.

 

I used this website to convert my doubles to binary, followed by this website to convert the concatenated binary to ASCII.

0 Kudos
Message 10 of 10
(860 Views)