LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem converting a string to array, and back again!

Hi,
 
I am usnig LabVIEW 7.1 and I'm having a bit of trouble converting an array to a string, and then back to an array again.
 
In the example below the contents of "Array" and "Array 2" are not the same. Can anyone solve this for me? I'm doing this so I can send array data over UDP (I can't change that unfortunately) - i.e. it has to be a string to send it, and then I need to decipher an ascii string into a I16 array.
 
 
Thanks.


Message Edited by russelldav on 05-14-2008 10:19 AM
0 Kudos
Message 1 of 13
(3,899 Views)
In LV 8.5 it works like you expect it to.
Regards,
André (CLA, CLED)
0 Kudos
Message 2 of 13
(3,889 Views)
Use the TypeCast function instead of what you're doing.




Message Edited by smercurio_fc on 05-14-2008 10:28 AM
Message 3 of 13
(3,888 Views)
Hi Russell,

as long as there is a coercion dot on the "u8 array to string" you will have problems receivin g correct values!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 13
(3,882 Views)
I've tried your setup, and it works without the UDP.  Maybe something subtle is different, but I've attached a version that works.
 
edit - wow, beaten several times


Message Edited by JeffOverton on 05-14-2008 11:34 AM
0 Kudos
Message 5 of 13
(3,877 Views)
If you do the attached it will work.  The datatype come out of the join function as a U16 so you need to type it as a I16 and it will read correctly.  It does look like a bug, since 8.5 works correctly without the type cast.



Message Edited by rpursley8 on 05-14-2008 11:59 AM
Randall Pursley
0 Kudos
Message 6 of 13
(3,866 Views)
Thanks for the suggestions.
 
I've tried using TypeCast functions and I get the same results. See below...
 
 
I can't use the example where the "type" is defined by linking to the original Array, as eventually the two arrays will be in different VIs on different PCs.
 
How can I clear the coercion dot on my original example (at the top of page 1)? What does it mean anyway?
 
Thanks



Message Edited by russelldav on 05-14-2008 11:49 AM

Message Edited by russelldav on 05-14-2008 11:49 AM

 

Edit: I just noticed in "Array 2" the correct data is there, it's just separated by a word that equals 0.



Message Edited by russelldav on 05-14-2008 11:51 AM
0 Kudos
Message 7 of 13
(3,840 Views)

JeffOverton - thanks for providing an example. I can't open anything newer than 7.1 though I'm sorry.

0 Kudos
Message 8 of 13
(3,828 Views)
I cracked open the copy of LabVIEW 7.1.1 that I still had on my PC and it works just fine.

Wonder if this is a 7.1 issue? I don't recall there be something specific to this.
Download All
0 Kudos
Message 9 of 13
(3,817 Views)


russelldav wrote:
I can't use the example where the "type" is defined by linking to the original Array, as eventually the two arrays will be in different VIs on different PCs.

Typecast is the only reasonable way to do all this. As type, you just create a diagram constant of an empty I16 array an all will be correct on the receiving end.


russelldav wrote:
How can I clear the coercion dot on my original example (at the top of page 1)? What does it mean anyway?

A coercion dot means that the datatype is different to what the function expects and an implicit conversion is taking place. Press ctrl+h to enable the context help and then hover over the wire going to the function. See if it is really a U8 array.


Message Edited by altenbach on 05-14-2008 10:09 AM
0 Kudos
Message 10 of 13
(3,816 Views)