LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to clean this string....

Hi all....
 
I want to tranform an array of strings into one string.
 
I've used array to spreadshett string and it's ok.
 
the real problem is that sometimes (like when the last position of the array is empty) the string contains some spaces  but i want nothing at the end.
 
How can i clean my string from additional spaces ecc at the end of it?
 
thank you

Message Edited by dario1979 on 04-24-2006 11:35 AM

http://www.sd-studio.it - web design agency
0 Kudos
Message 1 of 12
(3,774 Views)
How about the "Trim Whitespace" function? In the String->Additional String Functions palette.
Message 2 of 12
(3,765 Views)
Another approach would be to run your array of strings into a for loop with auotindexing enabled (the default) and concatenate the strings inside the loop. The Spreadsheet to string function adds delimiters which may be the cause of your extra characters.

This approach is not memory efficient, so use it with caution if your strings are large (MB to 100s of MB).

Lynn
Message 3 of 12
(3,761 Views)

I agree with Lynn.

😄

Message 4 of 12
(3,750 Views)
Are you talking (a) about extra characters in each array element, or (b) just at the end of the final string output?
 
If you don't want any delimiters, but just want to concatenate the strings, you can feed the string array into a "concatenate strings" node. No loop needed at all. 🙂
For (b), just trim the initial array from any empty string elements at the end of the array.
 
 
 

Message Edited by altenbach on 04-24-2006 11:39 AM

Message 5 of 12
(3,741 Views)

tnx to all

 

i'll try all solutions

 

cheers

 

dario

http://www.sd-studio.it - web design agency
0 Kudos
Message 6 of 12
(3,729 Views)


@altenbach wrote:
If you don't want any delimiters, but just want to concatenate the strings, you can feed the string array into a "concatenate strings" node. No loop needed at all. 🙂


Thanks Altenbach...  Wow..  I like it..

It rings a bell...  These are the little tricks you know (or have seen) about and forget.. 

Even the Context Help description reminds us... "Concatenate Strings:  Concatenates input strings and 1D arrays of strings into a single output string. For array inputs, this function concatenates each element of the array. ".. 

You'll have to start the "Altenbach Nuggets"  😉

Message Edited by JoeLabView on 04-24-2006 04:30 PM

Message 7 of 12
(3,714 Views)
hi altenbach
 
i try your solution and it works ok but my array contains some commands so i need the intermediate spaces but not at the end....
 
like:
 
ARRAY:                                               STRING
 
cmd1
cmd2
.....               ========>              {cmd1 cmd2.......cmdn}
.....
cmdn
 
 
tnx
http://www.sd-studio.it - web design agency
0 Kudos
Message 8 of 12
(3,685 Views)

Hi Dario,

Are you trying to achieve the string in the "loop string" display as shown below?

 

JLV

Message Edited by JoeLabView on 04-26-2006 09:35 AM

Message 9 of 12
(3,671 Views)
JLV, that's not a very efficient way of doing it, as in each loop you're requiring LabVIEW to allocate memory for a new string.

This is a very simple question, with a very simple answer. Just do the following:



Message Edited by smercurio_fc on 04-26-2006 08:46 AM

Message 10 of 12
(3,664 Views)