Split, combine ok but where's extract?

MisterX b.xavier at internet.lu
Sat Feb 12 01:29:43 EST 2005


Mark,

I did say I already wrote a function to extract these
but is there no split combination that does this without
a slow loop?

Here's the two functions I used

 function MergeColumns
  local xp,y,linecount,z,c
  put the paramcount into xp
  
  put empty into y
  put empty into linecount
  repeat with x = 1 to xp
    get param(x)
    get the number of lines in it
    put it & comma after linecount
  end repeat
  delete last char of linecount
  put max(linecount) into linecount
  
  repeat with x = 1 to linecount
    repeat with y = 1 to xp
      put line x of param(y) into z
      put z & comma after line x of c
    end repeat
    delete last char of c
  end repeat
  return c
end MergeColumns

function ExtractItems tabl,column,adelimiter
  if adelimiter is not empty then
    set the itemdelimiter to adelimiter
  end if
  
  local a
  put "" into a
  local x=1
  repeat for each line L in tabl
    put (item column of l) into line x of a
    add 1 to x
  end repeat
  return a
end ExtractItems

Of which the MergeColumn could use lots of optimizing ;)
But they're slow functions compared to split or combine.

If you extract the keys from a double array the problem
remains in the case of a second key name like

array[a,b]

where, for example, the b keys have to be extracted.
That's why I was wondering if there was a faster function...

Cheers
Xavier
--
http://MonsieurX.com

> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com 
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of 
> Mark Wieder
> Sent: Saturday, February 12, 2005 02:54
> To: 'How to use Revolution'
> Subject: Re: Split, combine ok but where's extract?
> 
> MisterX-
> 
> Friday, February 11, 2005, 9:07:06 AM, you wrote:
> 
> M> Just wondering if there is a simple way to extract the list of the 
> M> second key of an array
> 
> repeat for each line theItem in the keys of array
>   put item 2 of array[theItem] after field "myField"
> end repeat
> 
> -- same obviously for item 1
> 
> --
> -Mark Wieder
>  mwieder at ahsoftware.net
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 



More information about the use-livecode mailing list