I mean that always people say that you could use it in foreach statement and gives completely incorrect example as we saw there. So I tried to stress that initial value default is 1 not 0. Sure javadev can figure it out, but with wrong example in front of eyes it would be mentally harder. 2009/7/20 Nathan Bubna <nbu...@gmail.com>
> On Mon, Jul 20, 2009 at 7:02 AM, Alexander <the.malk...@gmail.com> wrote: > > > > Oh, didnt know that it can be configured, really thanks! Anyway default > behaviour not obvious for javadev. > > The rational was that it wasn't just meant for javadevs and javadevs > would be able to figure it out. I'm willing to reconsider this in > version 2. > > > 2009/7/20 Nathan Bubna <nbu...@gmail.com> > >> > >> On Mon, Jul 20, 2009 at 12:49 AM, lanxiazhi<lanxia...@gmail.com> wrote: > >> > thanks Rupali, > >> > I got this problem when I started to think that, can I simply output > an > >> > expression like #{1+2+200000*3+$a} without a varible? > >> > >> The macro is fine. Alternately, you could add an instance of the > >> MathTool (from VelocityTools) to your context and use that. > >> > >> ## this will have a newline char in it... > >> #set($newline="hello > >> ") > >> > >> and $velocityCount can be configured to start at any number: > >> > >> directive.foreach.counter.initial.value = 0 > >> > >> > 2009/7/20 Rupali Gupta <r.gup...@mpstechnologies.com> > >> > > >> >> Hi, > >> >> > >> >> > >> >> > >> >> Use $velocityCount in place where you need incremental value of some > >> >> variable > >> >> > >> >> Eg: instead of, > >> >> > >> >> > >> >> > >> >> #set($a = 0) > >> >> > >> >> #foreach($mapping in $mappings) > >> >> > >> >> Do something.. > >> >> > >> >> #set($a = $a+1) > >> >> > >> >> > >> >> > >> >> <label for="journal-$a">Type something</label> > >> >> > >> >> > >> >> > >> >> Do it like: > >> >> > >> >> > >> >> > >> >> #foreach($mapping in $mappings) > >> >> > >> >> Do something.. > >> >> > >> >> <label for="journal- $velocityCount ">Type something </label> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> $velocityCount increase the value of variable incrementally, without > having > >> >> to use ($a= $a+1) > >> >> > >> >> > >> >> > >> >> I hope this helps! > >> >> > >> >> > >> >> > >> >> Thanks, > >> >> > >> >> Rupali > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> _____ > >> >> > >> >> From: lanxiazhi [mailto:lanxia...@gmail.com] > >> >> Sent: Monday, July 20, 2009 12:52 PM > >> >> To: Velocity Users List > >> >> Subject: Re: simple problem > >> >> > >> >> > >> >> > >> >> we know this #set($a = $a + 1) will change $a which in some cases may > not > >> >> be > >> >> preferable...but thanks anyway. > >> >> > >> >> 2009/7/20 Alexander <the.malk...@gmail.com> > >> >> > >> >> Hi, > >> >> > >> >> > >> >> > >> >> Use > >> >> > >> >> > >> >> > >> >> #set($a = $a + 1) > >> >> > >> >> > >> >> > >> >> Correct me if Im wrong but if u use variable like this it would write > >> >> "hello" on a single line, where is the problem? > >> >> > >> >> > >> >> > >> >> #set($newline="hello") > >> >> > >> >> $newline > >> >> > >> >> > >> >> > >> >> > >> > > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org > >> For additional commands, e-mail: user-h...@velocity.apache.org > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org > For additional commands, e-mail: user-h...@velocity.apache.org > >