List manipulations

Sarah sarahr at
Thu Jun 6 20:55:01 CDT 2002

Hi Ron,

The most valuable thing to learn is the use of the "repeat for each" 
syntax. This is a screamingly fast way to cycle through your text.

It is also much faster to create a new list rather than altering the old 
one, so to add a new item (the same on each line), try something like:
	repeat for each line L in myList
		put item 1to 2 of L & comma & newStuff & comma & item 3 of L & 
return after newList
	end repeat

To extract certain columns:
	repeat for each line L in myList
		put item 1 of L & comma & item 3 of L after newList
	end repeat

.Supposing you have a separate list with the items that you need to 
insert into your first list, if you need to refer to the sub list by 
line number, it is faster if you transform it into an array first:

	split subList with return  -- it is now an array
	put 1 into theCounter     -- to keep track of which element to 
insert next

	repeat for each line L in myList
		put item 1to 2 of L & comma & subList[counter] & comma & item 
3 of L & cr after newList
		add 1 to counter
	end repeat

This last example looks like it would be easier using a "repeat with 
counter = 1 to the number of lines in myList" loop, but it is much 
faster to do it this way.

The other main speed tips are:
	1. always operate on variables rather than fields.
	2. too much updating of progress indicators can really slow things 


On Friday, June 7, 2002, at 11:27  AM, Ron wrote:

> Greetings
> I'm in the proces of moving a project to OS X that  uses a lot of 
> xthings to
> manipulate text and lists. These xthings will not be made useable on OS 
> X so
> I'm exploring transcripts aternatives. I won't ask for all of them at 
> once
> but I will start with a question of columns in hope that it will give 
> me the
> information that enables me to solve some of the other problems on my 
> own.
> Here goes.
> I simply want to add/extract columns of text of an existing list. So 
> with
> something like:
> a,b,c
> d,e,f
> g,h,i
> I would like to add an item between say item 2 and 3 (as delimited by 
> the
> comma) and I would like to extract items 1 and 3 from all the lines.
> This is somewhat simplified from what I do but I think it will point me 
> in
> the right direction.
> Thanks
> Ron
> _______________________________________________
> use-revolution mailing list
> use-revolution at

More information about the use-livecode mailing list