LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

slice string array with "spreadsheet string to array"

Hi
 
I have a very simple task, and I would like to solve it without FOR or any loops.
I have a string with 512 characters, and I want to create an array with 8char long strings. That means an array, with 64 elements, 8 character each.
I need it sequentially, so the first array element should contain the first 8 chars, the second element 9-16 chars...of the 512.
 
I tried to use "spreadsheet string to array" function, but I cannot figure out what to write to "format string".
 
Is it possible at all?
 
(I use LV 7.0)
0 Kudos
Message 1 of 6
(3,878 Views)
There may be some tricks to do that.  I can't find one off the top of my head, but my main question is why don't you want to use a loop.  The task is very easy with a loop, and in the end any function of subVI we find will end up using a loop.
0 Kudos
Message 2 of 6
(3,870 Views)

I spent way too much time trying to come up with an idea for this espically since I agree a loop would be the best choice.  But anyway, after considering type casts and flatten/unflatten from/to string (not working), the best I could come up with is to convert it to a 1D array of bytes, reshape the 1D array to a 2D array of 8x64, idex all 64 rows with one bit index array vi (my pic only shows 8 rows), convert those 1D arrays back to strings, use a build array to get the array of strings.

 

Again I think a much cleaner solution would be to use a loop!

Message Edited by paulmw on 11-08-2006 02:30 PM

Message 3 of 6
(3,848 Views)
That is exactly what I had come up with and couldn't figure a way to make it scalable without a loop.  Mitulatbati are you sure you will always have 512 characters, and that you won't want to expand or change this at any time?  Is there a reason you don't want a loop?
0 Kudos
Message 4 of 6
(3,832 Views)

Hi

thanks for the answers! Basically there is nothing against loops. But I thought that it is possible with the spreadsheet string to array vi. btw, my string is always 512 long.

0 Kudos
Message 5 of 6
(3,817 Views)
The Spreadsheet string to arry.vi would work if you had the string formated as a spreadsheet string.  A spreadsheet string requires an End Of Line constant (EOL is usually a carage return and lind feed both, i.e. two bytes) to separte the rows and user specified column deliminator (which you wouldn't need).  In your case you probably don't have the EOL in the string after every 8 bytes.  In that case you will get the same string back as the first element of the result array and all other elements are empty.  (P.S. the format specifier would be %s)
0 Kudos
Message 6 of 6
(3,800 Views)