LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Split a String into two Separate String

Solved!
Go to solution

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.

0 Kudos
Message 1 of 13
(2,283 Views)

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.

0 Kudos
Message 2 of 13
(2,274 Views)
Solution
Accepted by RoniWonders

snip.png

 

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

 

mcduff_0-1688686713339.pngmcduff_1-1688686730584.png

 

Message 3 of 13
(2,233 Views)
Solution
Accepted by RoniWonders

Here is a string version.

 

Split String.png

 

Message 4 of 13
(2,192 Views)

@mcduff wrote:

snip.png

 

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

 

mcduff_0-1688686713339.pngmcduff_1-1688686730584.png

 


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
0 Kudos
Message 5 of 13
(2,147 Views)

@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.

0 Kudos
Message 6 of 13
(2,111 Views)

One more String solution using @UliB quotient remainder

 

snip.png

Message 7 of 13
(2,096 Views)

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?

0 Kudos
Message 8 of 13
(2,126 Views)

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
0 Kudos
Message 9 of 13
(2,104 Views)

Please attach your Vi instead of pictures.

I don't think you need anything orange.

 

Your code is incredibly convoluted, why not so something simple as follows:

 

altenbach_0-1688756082173.png

 

0 Kudos
Message 10 of 13
(2,100 Views)