Re: Recursion within webmacro templates

Alex Twisleton-Wykeham-Fiennes <[email protected]> Mon, 6 Mar 2006 16:01:00 +0000
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
On Mon 6 March 2006 15:55, Holger King wrote:
> Hi Group,
>
> is it possible to realize a webmacro recursion within a webmacro
> template like:
>
> #macro counter($counterParam) {
>     CounterParam: $counterParam<br/>
>
>     #set $digit = $counterParam + 1
>
>
>     #if($digit < 10)
>         $digit < 10!
>         #counter($digit)
>     #end
>     #else
>         $digit >= 10
>     #end
> }
>
> #counter(1)
>
> I always get an StackOverflowError when calling the above template. If
> the are alternatives using other webmacro directives implementing a
> recursion logic, tell me further details. Thanx in advance.

#templet $counter {
  #set $digit = $digit + 1
  #if ($digit < 10) {
    [$digit < 10]
    #eval $Self using { "digit": $digit }
  } #else {
    [$digi >= 10]
  }
}
#eval $counter using { "digit": $digit }

gives me:-

[1 < 10] [2 < 10] [3 < 10] [4 < 10] [5 < 10] [6 < 10] [7 < 10] [8 < 10] [9 < 
10] [10 >= 10]  

Alex


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642