07-06-2023 03:22 PM
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.
Solved! Go to Solution.
07-06-2023 03:46 PM
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.
07-06-2023 06:39 PM
See if you can use String Functions; this one uses array functions.
07-07-2023 04:34 AM
Here is a string version.
07-07-2023 08:26 AM - edited 07-07-2023 08:32 AM
@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.
07-07-2023 10:24 AM
@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.
07-07-2023 12:38 PM
07-07-2023 01:25 PM
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?
07-07-2023 01:53 PM - edited 07-07-2023 01:54 PM
Hi Roni,
@RoniWonders wrote:
What am I doing wrong?
It could as easy as this:
07-07-2023 01:55 PM
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: