[ic] loop-last based on a scratch value

Grant listbox at email.com
Fri Nov 7 14:13:54 EST 2003


>
> At 03:57 PM 11/7/2003 -0500, you wrote:
> >Quoting Ed LaFrance (edl at newmediaems.com):
> > > At 11:14 AM 11/7/2003 -0800, you wrote:
> > >
> > > >> > > The following doesn't work.  Is it a syntax problem, or is a
> > > >> loop-last
> > > >> > based
> > > >> > > on a scratch value just not going to happen?
> > > >> > >
> > > >> > > [loop-last][loop-calc] return 1 if
> $Scratch->{listing_counter} == 4;
> > > >> > > [/loop-calc][/loop-last]
> > > >> >
> > > >> >I think it is pretty obvious from the documentation that
> you need the
> > > >> >regular calc tag inside of the loop-last.
> > > >> >
> > > >> >Bye
> > > >> >         Racke
> > > >>
> > > >> Stefan is quite right, so to correct my earlier answer:
> > > >>
> > > >> [loop-last][calc] return 1 if $Scratch->{listing_counter} == 4;
> > return 0;
> > > >> [/calc][/loop-last]
> > > >>
> > > >> http://www.icdevgroup.org/i/dev/docfly.html?mv_arg=ictags04.44
> > > >>
> > > >> - Ed
> > > >
> > > >I tried all kinds of things before my first message to the
> list about
> > this.
> > > >Using your suggestion above, I just tried this:
> > > >
> > > >[loop list="1 2 3 4 5 6 7 8 9"]
> > > >[tmp listing_counter][calc] [scratch listing_counter] + 1
> [/calc][/tmp]
> > > >[loop-last][calc] return 1 if $Scratch->{listing_counter} >
> 1; return 0;
> > > >[/calc][/loop-last]
> > > >[loop-code] - [scratch listing_counter]
> > > >[/loop]
> > > >
> > > >and it iterates all 9 times.
> > > >
> > > >- Grant
> > >
> > > See yesterday's message on interpolation order; nothing happens with
> > > [scratch listing_counter] in your code until all [loop]'ing
> is done. Try
> > > something like this instead:
> > >
> > > [set listing_counter][/set]
> > > [loop list="1 2 3 4 5 6 7 8 9"]
> > > [loop-last][calc]return 1 if ++$Scratch->{listing_counter} > 1; return
> > > 0;[/calc][/loop-last]
> > > [loop-code] - [scratch listing_counter]
> > > [/loop]
> >
> >Actually in this case it does. Part of the deal with [loop-last] is that
> >it does interpolate contained ITL.
> >
> >--
> >Mike Heins
>
> No doubt you could explain it more eloquently than I, but this works:
>
> [set listing_counter][/set]
> [loop list="1 2 3 4 5 6 7 8 9"]
> [loop-last][calc]return 1 if ++$Scratch->{listing_counter} > 1; return
> 0;[/calc][/loop-last]
> [loop-code] - [scratch listing_counter]<br>
> [/loop]
>
> ...and this does not:
>
> [loop list="1 2 3 4 5 6 7 8 9"]
> [tmp listing_counter][calc] [scratch listing_counter] + 1 [/calc][/tmp]
> [loop-last][calc] return 1 if $Scratch->{listing_counter} > 1; return 0;
> [/calc][/loop-last]
> [loop-code] - [scratch listing_counter]
> [/loop]

Very true, and I think it would be better if [loop-last] worked like Mike
describes with automatic interpolation of ITL within
[loop-last][/loop-last].

Thank you Paul and Ed for that code.  It does work in the example I gave,
but the point of having [loop-last] based on a scratch value is that a
scratch value need not only be based on the number of times the loop has
iterated.  [loop-increment] could be used for that.  In the code above,
"listing_counter" will be incremented each time the loop iterates no matter
what, right?  That doesn't allow you to use a conditional statement to
increment "listing_counter" or not.  It looks like that's just not possible?

- Grant



More information about the interchange-users mailing list