# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Split a String into two Separate String

Hi so I'm trying to split a string into two halves then put them back together with the second character separating them. For example, if the string is "apple", I want to it to be divided as "app" and "le" then put the back together with "p" in the middle to make "lepapp". I've been trying to use the Search/Split String but I'm not able to get the second half of the string.

I've figure it out with an even number of characters string like "home" to make "meoho" but it's the odd strings that make it confusing to me.

Message 1 of 13
(1,996 Views)

## Re: Split a String into two Separate String

Hi Roni,

You are on the right track using "Search/Split String".

The second half of your string would be the "match + rest of string" output. Also, for odd numbers, since you want to split after the middle character, you could divide the size of the original string by 2 and round up with "Round Toward + Infinity" to compute the split offset.

Regards,

Raphaël.

Message 2 of 13
(1,987 Views)
Solution
Accepted by topic author RoniWonders

## Re: Split a String into two Separate String

See if you can use String Functions; this one uses array functions.

Message 3 of 13
(1,946 Views)
Solution
Accepted by topic author RoniWonders

## Re: Split a String into two Separate String

Here is a string version.

Message 4 of 13
(1,905 Views)

## Re: Split a String into two Separate String

@mcduff wrote:

See if you can use String Functions; this one uses array functions.

Nicely done! But, the decrement is not necessary 😕 delete from array defaults to last value!  Also, the To I32 is ( in this case) better handled as an implied coercion.  Those coercion dots are not always evil!  I actually like the Quotient + Remainder Mod 2 demonstrated by Ulib.

"Should be" isn't "Is" -Jay
Message 5 of 13
(1,860 Views)

## Re: Split a String into two Separate String

@JÞB wrote:
Those coercion dots are not always evil!  I actually like the Quotient + Remainder Mod 2 demonstrated by Ulib.

I like Ulib Remainder Mod too. Agree about coercion dots, but the OP appeared to be relatively new to LabVEIW so tried to show best practices, which may not be necessary true or needed for all cases.

@JÞB wrote:

But, the decrement is not necessary 😕 delete from array defaults to last value!

I am allergic to Delete from Array. 🙂 In this case it does not matter, but it always gives buffer allocations which I don't like.

Message 6 of 13
(1,824 Views)

## Re: Split a String into two Separate String

One more String solution using @UliB quotient remainder

Message 7 of 13
(1,809 Views)

## Converting ASCII code to Hexdecimal String

So I have set up the program to convert the code to hexadecimal however it isn't fully putting out the hexadecimal.

For example, I want convert "skede" to hexadecimal which would be "736B656465" however it only displays "736B6564". Its missing the last letter which would be "65". What am I doing wrong?

Message 8 of 13
(1,839 Views)

## Re: Converting ASCII code to Hexdecimal String

Hi Roni,

@RoniWonders wrote:

What am I doing wrong?

• You don't care about coercion dots.
• You use a rounding function.
• You do your stuff way to complicated…
• You don't provide code. Keep in mind: we cannot debug/edit/run images in LabVIEW!

It could as easy as this:

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 13
(1,817 Views)