LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert string to integer array

Solved!
Go to solution

Hi,

 

I'm reading a packet with TCP Read.  The data out is a string o 248 bytes.  I need to convert that to an array of  62 U32's.  I tried type casting in a loop but that didn't work.

 

What's the correct way to perform the conversion?

 

Thanks.

 

0 Kudos
Message 1 of 10
(7,704 Views)
Just typecast to a U32 array. No need to use any type of loop.
0 Kudos
Message 2 of 10
(7,697 Views)
there are string convertions uder the string pallette that may help
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 3 of 10
(7,695 Views)

Harold Timmis wrote:
there are string convertions uder the string pallette that may help

Why would you go through a string?

 

To original poster: As Dennis indicated, you do not need a loop. Byte endianness may be a problem, though. Do you know what this is for the source data?

0 Kudos
Message 4 of 10
(7,693 Views)

I'm using a string because that's what TCP Read's data out is.  Is there some way to change that?

 

0 Kudos
Message 5 of 10
(7,687 Views)

When I simply type casted, all I got was a single value I did not get an array.  I think the single value was simply the first four bytes of the string. That's why I tried a loop.

I think I'm misssing something with type casting.

0 Kudos
Message 6 of 10
(7,680 Views)
Solution
Accepted by topic author JohnSantaFe

Smercurio_fc is right. I forgot about the endianess. Instead of the type cast, you could use the Unflatten From String. Depends on what is generating the data.

 

No, the TCP/IP Read output is only a string.

0 Kudos
Message 7 of 10
(7,675 Views)

JohnSantaFe wrote:

When I simply type casted, all I got was a single value I did not get an array.  I think the single value was simply the first four bytes of the string. That's why I tried a loop.

I think I'm misssing something with type casting.


Did you do this:

Message 8 of 10
(7,671 Views)

JohnSantaFe wrote:

When I simply type casted, all I got was a single value I did not get an array.  I think the single value was simply the first four bytes of the string. That's why I tried a loop.

I think I'm misssing something with type casting.


 

You definitely did something wrong if the type case did not return an array. Are you sure you have a U32 array wired to the type input?
Message Edited by Dennis Knutson on 09-17-2009 12:24 PM
0 Kudos
Message 9 of 10
(7,669 Views)

Ah that's it.  I had wired just an integer to the type for the type cast and not an integer array.

 

Thanks to everyone for your help.

 

 

0 Kudos
Message 10 of 10
(7,634 Views)