[ic] loop-last question

Ed LaFrance edl at newmediaems.com
Tue Oct 14 10:24:28 EDT 2003


At 08:15 AM 10/14/2003 -0700, you wrote:

> > Grant <listbox at email.com> wrote:
> > >> Thanks Chris.  I didn't know what loop-increment was.  Time to
> > >> get rid of my
> > >> counters.  Thanks to your help I've got loop-last doing what I need.
> > >> But I'm wondering if there's a way to use it without calc.  Here's
> > >> an example that works with calc:
> > >>
> > >> [loop search="ml=10000/ra=yes"]
> > >> code: [loop-code]<br />
> > >>    [loop-last][calc] return '[loop-code]' eq 'sku-20';
> > >> [/calc][/loop-last] [/loop]
> > >>
> > >> How could it be written without calc?
> > >>
> > >> - Grant
> > >
> > > Can loop-last be used without calc?  I'm asking because I'm under the
> > > impression that calling calc or perl results in a performance hit.
> > >
> > > - Grant
> > >
> >
> > http://www.icdevgroup.org/i/dev/docfly.html?mv_arg=ictemplates05%2e04
> >
> >
> > [loop-last]tags[/loop-last]
> >
> > Evaluates the output of the ITL tags encased in the [loop-last]
> > tags. If it
> > evaluates to a numerical non-zero number (for example, 1, 23, or
> > -1), the loop
> > iteration will terminate. If the evaluated number is negative,
> > the item itself
> > will be skipped. If the evaluated number is positive, the item
> > itself will be
> > shown, but will be last on the list.
> >
> >
> > Paul
>
>I've been over and over those docs, and what I thought after reading them
>was that something like [loop-last]1[/loop-last] inside a conditional
>statement would terminate the loop once the condition was met.  After some
>testing and some info from the list, it seems like it just doesn't work like
>that.  [loop-last]1[/loop-last] must be parsed if it exists in a loop
>whether or not that particular line is being executed.  I hope I'm making
>sense.  Taking all of that into account, I don't think there is a way to use
>loop-last without calc or perl.  Is there?
>
>- Grant

I think you are running up against an issue of interpolation order. 
[prefix-*] tags on a page will be parsed before other tags like [if], so 
you can't really do something like:

[loop arg="foo"]
[if scratch something eq this]
         [loop-last]1[/loop-last]
[/if]
[/loop]

... because the [loop-last]..[/loop-last] gets parsed before the enclosing 
[if][/if] is even considered.

- Ed L.


===============================================================
New Media E.M.S.              Technology Solutions for Business
11630 Fair Oaks Blvd., #250   eCommerce | Consulting | Hosting
Fair Oaks, CA  95628          edl at newmediaems.com
(916) 961-0446                http://www.newmediaems.com
(866) 519-4680 Toll-Free      (916) 961-0447 Fax
=============================================================== 



More information about the interchange-users mailing list