Re: [Zope-dev] Iteration counter

2001-12-18 Thread Danny William Adair

> > I will need to use the $counter variable later on in the script.

Oh sorry, forgot that one...

Inside your loop, you can do:




But then again, this would only give the _total_ number of iterations that 
have been made. If you only need this number :-), then please forget 
everything that I wrote, and just use
sequence-length
or
_.len(WhatYouAreIteratingThrough)

Since you can't break out of a dtml-in, the number of iterations that will be 
made will always be equal to the number of items ("length") in your sequence.

Danny

P.S.: All this should be on [EMAIL PROTECTED], rather than zope-dev

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Iteration counter

2001-12-18 Thread Danny William Adair

On Wednesday 19 December 2001 10:11, Jon Erickson wrote:
> I need a to create a simple counter variable that will store the number of
> iterations by a  structure.  I have yet to find a way how to do
> this in zope.  Here is an example (in perl) of what I need to do:

The number of iterations are already available as:
sequence-index (starting at 0) and
sequence-number (starting at 1)

hth,
Danny

>
> @bar = ("sara","jane","kate");
>
> foreach $foo (@bar) {
>   print "$foo\n";
>   $counter = $counter + 1;
> }
>
> I will need to use the $counter variable later on in the script.  Does
> anyone know how I can do this in zope?
>
> Thanks,
>
> Jon Erickson
>
>
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] Iteration counter

2001-12-18 Thread Jon Erickson

I need a to create a simple counter variable that will store the number of 
iterations by a  structure.  I have yet to find a way how to do 
this in zope.  Here is an example (in perl) of what I need to do:

@bar = ("sara","jane","kate");

foreach $foo (@bar) {
  print "$foo\n";
  $counter = $counter + 1;
}

I will need to use the $counter variable later on in the script.  Does 
anyone know how I can do this in zope?

Thanks,

Jon Erickson


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )