LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding into middle of string. I want to have a string that entered as 1-5 to read out as 1 2 3 4 5. Is there a easy way to do this?

Hi Hobart,

1) parse the string to get start and end number (split string at "-"-sign, convert strings to numbers).
2)  make a for loop with iteration count  (end-start+1), wire the "i" to the border of the for loop.
3) add "start" to the resulting array of numbers
4) convert to string by "array to spreadsheet string" using space as separator

You're done!

There are other ways as well, but this one is straight-forward.


Message Edited by GerdW on 01-25-2008 08:57 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(3,507 Views)
Hello,

See the attached vi for an example of one way to solve this problem.  It is easy to modify if your formatting is different than how I did it.

Cheers!
0 Kudos
Message 3 of 8
(3,504 Views)
Hi jmcbee,

in your example I would replace the string formatting inside the loop with a single "format into string" using " %d" as format string.
Your example also relys on 1 as the first number of the range...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(3,502 Views)
GerdW is correct so if you use my VI as a starting point be sure to implement what GerdW wrote in the above post.  That is what I get for being quick and dirty.  See attached vi for a better place to start than what I posted above! (GerdW, do you think it is best to keep as Integer Array until outside of the loop completely, it seems to me that this is the way to go but I am up for other ideas!)

Cheers!


Message Edited by jmcbee on 01-25-2008 01:09 PM
0 Kudos
Message 5 of 8
(3,500 Views)
Made another mistake.  Use this one instead.  I forgot to flip the second number back around so for 100 it was seeing 001.  Now this is fixed.
0 Kudos
Message 6 of 8
(3,494 Views)
I do not know if it is more efficient to convert to a string inside the for loop or to wait and convert the entire integer array into a spreadsheet string outside the for loop.  Does anybody know which is better concerning memory efficiency?


Message Edited by jmcbee on 01-25-2008 01:31 PM
0 Kudos
Message 7 of 8
(3,489 Views)
Thanks. At least I wasn't way off. Thanks again.
0 Kudos
Message 8 of 8
(3,471 Views)