spliting a big string into smaller variables
- Suppose I have a string like the following:
title 1 some text title 2 other text 567034
How can I split this line upto into variables so I can use it in a
etc would appear.
We can assume that space is the field seperator.
- dvdwriters12 wrote:
> Suppose I have a string like the following:Hopefully this helps:
> title 1 some text title 2 other text 567034
> How can I split this line upto into variables so I can use it in a
> wizard ?
> etc would appear.
> We can assume that space is the field seperator.
;*** Effort by Don Passenger
;*** discuss things live in chat at http://htmlfixit.com
;I assume each line in the file is this 9 field data format:
;"title 1 some text title 2 other text 567034"
;start at the top (assuming whole file)
;set list delimiter to space and get array elements
^!SetListDelimiter " "
;get the row we are in
;select the current line where cursor resides
;this will select the entire line from prior
;line feed to this one
;delimited array set by splitting line on spaces
;display each array element
^!Info Row is: ^%row% ^PElement ^%indx% is ^%delimited_data^%indx%%
;check if we have used all elements in current row
;compare current index number to number of elements
;in the array using delimited_data0 - which stores
;the number of elements in an array
^!If ^%indx% = ^%delimited_data0% Next_Line
;move to next line and then continue
;go to next line
;loop again if there are more rows
^!If ^%row% = ^$GetLinecount$ END ELSE Loop
As usual I post my clip for later retrieval here:
If you have an improvement or comment feel free to leave it over there
As I didn't exactly know what you wanted to do, I just took the fields
to an info box. When you split on a delimiter, in this case a space,
you get an array that contains the number of elements between the
delimiters (in this case 9), plus a special 0 element which is the
number of elements in the array. So you can address each element in the
array using variablename1-9. If you don't know how many elements there
might be, you check variable_name0 to find out.