repeat with each woord currentWord in myString

A.C.T. albrecht at act-net.com
Sat Mar 20 16:14:08 EST 2004


Moin,


> And so... (drum roll please)... it would be much more efficient if there 
> were some way to grab each chunk sequentially, without the engine being 
> forced to re-count from the beginning every time through. Thus, a 
> special construct:
> 
> repeat for each word someWord in someVariable
>    doSomething someWord
> end repeat

I don't know (yet) how fast the script interpreter is with (large) 
arrays, but a common way of handling large numbers of "chunks" like this 
is to put them into an array, if you really need to "reuse" them or 
access them randomly:

put 1 into counter
repeat for each word someWord in someVariable
put someWord into wordarray[counter]
increment counter by 1 # don't know if Transcript can do this,
# the proper way would be to say "counter++", naturally
end repeat


This way you could easily access each word on a DIRECT way using 
"wordarray[whatever]". Ok, memory usage is doubled (since you put copies 
of the words into the array elements), but speed should be no problem 
any longer (if the interpreter handles arrays sufficiantly). Please note 
that my "Transcript" most likely won't work, but you should be able to 
get the idea, I hope.

Mit freundlichen Grüßen,
Marc Albrecht
A.C.T. / Level-2
Glinder Str. 2
27432 Ebersdorf
Deutschland
Tel. (+49) (0)4765-830060
Fax. (+49) (0)4765-830064


More information about the use-livecode mailing list