what form of "split" turns a tab-delimited variable into an array with the first line as keys?

Michael Kann mikekann at yahoo.com
Fri Apr 9 10:49:11 EDT 2010


Using asterisks instead of tabs, put 

name*color*food
Trevor*green*salad
Sarah*blue*pizza

into fld 1
----------------------------------
Use this script:
----------------------------------
on mouseUp
set the itemDelimiter to "*"
put fld 1 into v
put line 1 of v into headers_line
delete line 1 of v
-------------------------------
put zero into line_num

repeat for each line c_line in v
add 1 to line_num
put zero into item_num

repeat for each item c_item in c_line
add 1 to item_num
put item item_num of headers_line into x
put c_item into josh_array[x][line_num]
-------------------------------
-- next two lines are just
-- to view the resulting array
-------------------------------
put josh_array[x][line_num] into y
put x && line_num && y && return after h
-------------------------------
end repeat
end repeat

put h into fld 2
end mouseUp



--- On Fri, 4/9/10, Josh Mellicker <josh at dvcreators.net> wrote:

> From: Josh Mellicker <josh at dvcreators.net>
> Subject: what form of "split" turns a tab-delimited variable into an array with the first line as keys?
> To: "how to use Revolution" <use-revolution at lists.runrev.com>
> Date: Friday, April 9, 2010, 2:07 AM
> Given a variable like this, where the
> first line is "headers":
> 
> name  [tab]  color  [tab]  food
> Trevor  [tab]  green  [tab]  salad
> Sarah  [tab]  blue  [tab]  pizza
> Richard  [tab]  orange  [tab]  burgers
> David  [tab]  purple  [tab]  fruit
> 
> What is the best way to turn this into an array, where the
> array keys are the first line of the variable?
> 
> I have tried various forms of "split by" ""split using" and
> ""split with" but haven't found the right formula.
> Personally I find the documentation on the various forms of
> the "split" and "combine" commands a bit scant.
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 


      



More information about the use-livecode mailing list