LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

manipulating strings

Solved!
Go to solution

I'm working my way with the homework, and I been searching the web about concatening the word into two substrings. However, how do I tell it so it knows that it always separates it 50%? Meaning half the word goes in the 1st indicator and the other half goes into the 2nd indicator. At the moment, I have to manually set the count, but this won't work if I type in a different word obviously.

0 Kudos
Message 1 of 7
(2,686 Views)

(Splitting a string into two is the opposite of concatenating, so make sure to keep the terminologies straight.)

 

You can only split it in two if the string lenght is an even number, else you need to decide with side should be longer by one.

 

In any case, the string palette has a primitive called "string length" that could provide useful for this problem. Try using it.

 

See how far you get. 😉

Message 2 of 7
(2,683 Views)

thanks for the correction.

 

Umm I don't see how the string length will help me, I've wired it to the input, but won't that just take the length of the word I put in? you mentioned that if it was an even number word, that I could split it easily. Do I have to change something in the offset to do so, extactly half? Right now I have it set to 3 but I know that can't be right

0 Kudos
Message 3 of 7
(2,680 Views)

What if you would divide the lenght by two and wire it into the split string primitive, replacing the current diagram constant?

Message 4 of 7
(2,676 Views)

Divide the string length buy two and then select the subset of the string using half the length as either the length or the offset.

 

Ex. 

 

string = "SplittingStrings"

length = 16

length/2 = 8

 

subset with offset equal to 8 = SplittingStrings = "gStrings" (by the was that was totally not intended ahead of time)

subset with length equal to 8 = SplittingStrings = "Splittin"

 

Either way, the subset you get will be one indicator and the rest of the string wil be your other indicator.

 

As altenbach said, notice this worked well with a string with an even length.  If the length is odd, you will have to round it and have uneven substrings.

Chris
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 5 of 7
(2,674 Views)
Solution
Accepted by topic author LABVIEW321

@PackersFan wrote:

As altenbach said, notice this worked well with a string with an even length.  If the length is odd, you will have to round it and have uneven substrings.


You don't want to use the plain divide operation, because it will give you an orange output. Use quotient and remainder to keep it blue at all times. 😉

 

  • To round down, use the floor output
  • To round up, add the remainder to the floor output (if dividing by a number that is larger than two, apply the sign function to the remainder first)
Message 6 of 7
(2,668 Views)

awesome!, Thank you! That help me solved a bunch of steps so far, I'm going to see how far I can get and take some time to figure it out before replying back.

 

0 Kudos
Message 7 of 7
(2,667 Views)