LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting character string to array

Hello
 Is it possible to convert a character string e.g "current" to an array to include it as part of an array of data. i.e to apprear at the end or beginning of the array.
 
Thanks,
  Liam.
0 Kudos
Message 1 of 8
(29,323 Views)

Yes.

On the functions pallette...

String -> Conversion -> String to byte array

Rod.

 

Message 2 of 8
(29,319 Views)
What exactly do you mean? Do you want an array with each character as an element or something else? To include the entire string to an existing array, you can simply use the Build Array function.
0 Kudos
Message 3 of 8
(29,315 Views)

Does string to byte array not give me just a numerical representation of "current". I need it to look like the word itself. My array should look like

Current   Voltage

1.2            .557

1.3            .567

 

etc

But if I use the byte array I get numerical representations of the words current and Voltage.

Liam.

0 Kudos
Message 4 of 8
(29,301 Views)
You still haven't really explained what you want to do with this array. An array can contain only one type of data. If you want to display this information in a table on the front panel, then because a table is 2D array of strings, you have to convert the numerics to a string first. If you want to save this information to a file, then you can first write the header as strings and then write the numeric array. You can of course, write it all at once if you convert everything to strings.
0 Kudos
Message 5 of 8
(29,298 Views)

I think what he's trying to say Dennis is basically what you explained.  First column being Current, 1.2, 1.3 and the second column being Voltage, 0.557, 0.567; which would require the converting of everything to strings as you mentioned.

Trying to clarify things a bit, making a Friday as good as it should be Smiley Very Happy

0 Kudos
Message 6 of 8
(29,288 Views)

Hello again,

   Yes the problem is that on converting everything to strings I cannot write it to an origin project using the OA communication VI's written for use under labview. I need to be able to append the string to the top of the array so that it appears as headers on the worksheet.

 

Ta

Liam.

0 Kudos
Message 7 of 8
(29,237 Views)
By their very nature, you cannot mix data types in an array. I have no idea what origin is or how you are passing data to it but if you are passing an array directly to it and it requires a numeric array, there is no way to append headers in LabVIEW or any other language. Where did you get these VIs for talking to this other program? Maybe it just requires a modification to the VI that you are using to accept string arrays. Have you looked at the block diagram? Can you provide the VIs or a link to them?
0 Kudos
Message 8 of 8
(29,218 Views)