using "repeat for each" when you don't want to start with thefirst line

shop shop at paynesparkman.com
Mon Apr 29 11:30:00 EDT 2002


I thought of a similar approach shortly after posting where I put the
selectedtext into a variable then compare that variable with each line L.
If they don't match then next repeat.  The problem with both of these
approaches is that they both involve checking potentially hundreds of lines
before getting to the one where I actually want to start.  This seems
pointless since I already know at which line to start based on the users
selection.  My original code skips all those preceding lines and starts with
the user-selected line.  I suspect this might be faster than using "repeat
for each" on every line if there are a sufficient number of lines preceding
the one I want to start with.  I just saw LiangTyan Fui's post where he
suggests the following:

put the SelectedText of fld "Scene List" into CurScene
put lineoffset(CurScene&return,SceneFile) into q
put SceneFile into SceneFile2 # If you need to preserve SceneFile, or else
delete from it directly.
delete line 1 to q of SceneFile2 # MC handle small chunk faster
repeat for each line theline in SceneFile2
      do stuff
end repeat

I'm confident that MC can delete a block of lines much faster than it can
check each of those lines for a match, which makes this a better solution.
Despite this, your suggestion is still valuable, David, because it helps
point out this distinction.  Thank you both.

Rich Mooney
Payne Sparkman Mfg.
shop at paynesparkman.com
----- Original Message -----
From: "David Tremmel" <david.tremmel at duke.edu>
To: <metacard at lists.runrev.com>
Sent: Monday, April 29, 2002 10:20 AM
Subject: Re: using "repeat for each" when you don't want to start with
thefirst line


Off the top of my head, here's one approach -

put 1 into i
repeat for each line L in fld "Scene List"
  if i >= the selectedLine of fld "Scene List" then

    do stuff (note that the current line is in the variable L)

  end if
  add 1 to i
end repeat


Regards,
Dave Tremmel


On 4/29/02 10:01 AM, "shop" <shop at paynesparkman.com> wrote:

> I have a number of repeat loops in my software which I would love to speed
up
> using the "repeat for each" technique but I don't want to start with the
first
> line.  Instead, I want to start based on which line the user selects in a
fld.
> A typical example of what I'm currently doing follows:
>
>   put the SelectedText of fld "Scene List" into CurScene
>   put lineoffset(CurScene&return,SceneFile) into q
>   repeat with q2 = q+1 to the number of lines in SceneFile
>         do stuff
>   end repeat
>
> Any suggestions?
>
> Rich Mooney
> Payne Sparkman Mfg.
> shop at paynesparkman.com
>



--
David Tremmel
RooTracker Developer

Duke University
Phytotron Bldg.                                 Phone:  (919) 660-7415
Box 90340                                       FAX:    (919) 660-7425
Durham, NC  27708-0340                          E-mail: rootracker at duke.edu






More information about the metacard mailing list