Split, combine ok but where's extract?
Alex Tweedly
alex at tweedly.net
Sat Feb 12 06:52:02 EST 2005
MisterX wrote:
>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
>end MergeColumns
>
I'm still trying to understand just what that one does (in all cases) so
I'll start with the simpler one.
>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
>
>
x is used only to count the number of lines,and changed only when a new
line is added the end - so just use "put after"
function ExtractItems tabl,column,adelimiter
local a
if adelimiter is not empty then
set the itemdelimiter to adelimiter
end if
repeat for each line L in tabl
put (item column of L) & cr after a
end repeat
delete the last char of a
return a
end ExtractItems
>Of which the MergeColumn could use lots of optimizing ;)
>But they're slow functions compared to split or combine.
>
>
I can't see a way to use split/combine (except for the special case of
first col).
--
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