velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Can a variable have local scope?
Date Fri, 13 Jul 2001 02:38:33 GMT
Uday Kumar wrote:
> 
> hi
> 
> Can I have a variable with local scope in velocity? I wrote a macro that
> calls itself again and again and I have defined a variable in that macro and
> set it to 1. Each time the macro calls itself, the variable is incremented
> by 1. but, when the control comes back to the calling macro, the old value
> is not retained and instead the new value is being used. (The application
> that I am using here is like printing a binary tree)
> 
> Please help me in this regard

Yes, only in a Velocimacro.  Try this :

 velocimacro.context.localscope = true

geir


> -Uday
> 
> ----- Original Message -----
> From: "Tim Colson" <tcolson@cisco.com>
> To: <velocity-user@jakarta.apache.org>
> Sent: Thursday, July 12, 2001 10:14 AM
> Subject: RE: calling setProperty(float) not possible ?
> 
> >
> > > Velocity will recognize as arguments to directives, velocimacros and the
> > > RHS of #set() :
> > > snip
> > Say - is this good stuff in the docs? If not, please consider adding it as
> > an additional section "Geeky Details". Seriously, it's good to know.
> >
> > > With strings, '$foo' is handled literally, "$foo" is actually
> > > 'rendered'.  So you can get away with all sorts of wacky things
> > Cool - you can do interpolation on strings and even use directives!
> >
> > Diabolically yours,
> > Tim
> >
> >

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Mime
View raw message