LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract blocks strings of length 4 into array

Hello,

 

I am attempting to place a string into an array.  However, the length of the strings should be 4.

 

If my input is ABCD0122FFEA the output array should be

ABCD

0122

FFEA

 

Thanks!

0 Kudos
Message 1 of 4
(753 Views)

@hiNI wrote:

Hello,

 

I am attempting to place a string into an array.  However, the length of the strings should be 4.

 

If my input is ABCD0122FFEA the output array should be

ABCD

0122

FFEA

 

Thanks!


Your code is more complicated than it needs to be (besides not working correctly).  Think about your requirement.  Isn't this really about ripping the first four characters out of your string, placing it into an element, then repeating this until you have no more characters left?

 

HINT: Look in Additonal String Functions to see if you can find anything useful there.

 

Note:

If this was a message that needed to be decoded as three chunks of data, I might approach this differently.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 4
(750 Views)

You were actually pretty close.  I removed the initial String Subset that was outside of the loop and then got rid of the Shift Register.  A little more cleaning up and this was my result.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
0 Kudos
Message 3 of 4
(694 Views)
  • Is the string length guaranteed to be divisible by four? Is it always 12? Can the size be very large?
  • What should happen if the size is not divisible by four (truncate? Pad with special character? Last element has less than 4 characters?)
  • Why did you not wire the substring length?
  • Why do you also take a substring before the loop?
  • What's the purpose of the indicator named "substring"?
  • Why do you think you need a shift register?
  • ...

 

altenbach_0-1632833283082.png

 

(can be simplified depending on how much is known about the input, see above)

0 Kudos
Message 4 of 4
(688 Views)