Split, combine ok but where's extract?

Alex Tweedly alex at tweedly.net
Sat Feb 12 07:16:44 EST 2005


MisterX wrote:
I can't see any radically different approach - but you can certainly 
optimize the details

> 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
>    put the number of lines in param(x) & comma after linecount
>  end repeat
>  delete last char of linecount
>  put max(linecount) into linecount
>  
>

Then either

>  repeat with x = 1 to linecount
>    repeat with y = 1 to xp
>      put line x of param(y) & comma after line x of c
>    end repeat
>    delete last char of c
>  end repeat
>  
>
or (probably better)

>  repeat with x = 1 to linecount
>    repeat with y = 1 to xp
>      put line x of param(y) comma after c
>    end repeat
>    delete last char of c
>    put cr after c
>  end repeat
>  
>

It would be worth experimenting with turning the loop inside out

   repeat with x = 1 to xp
     put param(x) into theLine
     repeat with y = 1 to linecount
       put line y of theLine & comma after line y of c
     end repeat
   end repeat
   repeat with y = 1 to linecount
      delete the last char of line y of c
   end repeat

but I don't think that will be faster.

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.7 - Release Date: 10/02/2005



More information about the use-livecode mailing list