Thanks for the reply, Christoph. $mrank returns a number from 1 to 70 $mrank.class.name does not return anything.
I had tried the #elseif cascade originally, but since the comparisons were not working, I simplified in an attempt to narrow down the problem. Unfortunately, it hasn't. Yes, everthing ends up in the #else branch using that method. Still no luck, though. gmc On Thu, Nov 4, 2010 at 11:06 AM, <apa...@recks.org> wrote: > Hi, > > please check what your $mrank object contains: > print it out: $mrank > check the class of it: $mrank.class.name > > Also you would profit from an #elsif cascade. > > #if ($mrank <= 30) #set ($n = $MS1.add($record)) > #elsif ($mrank >= 60) #set ($n = $MS3.add($record)) > #else #set ($n = $MS2.add($record)) > #end > Here, if the comparisons where not possible, due to the class behind > $mrank, everything would end up in the #else branch. > > OTOH... some purists would cry-out that templates are not the place to code > business-logic... > > Hope this helps, kind regards, > Christoph > > > Gary Catlin on 2010-11-04 14:38 wrote: > >> Hello All, >> >> Does anyone know why the code below is not working as intended? I am >> attempting to group the records in $Array by the value of $Array.Rank. I >> have examined the contents and $Array.Rank returns values between 1 and >> 70, >> as expected. The conditions in my 3 #if statements don't seem to be >> getting >> activated, and $MS1/2/3 are empty. >> >> Thank you. >> >> #set ($MS1 = []) >> #set ($MS2 = []) >> #set ($MS3 = []) >> #set ($mrank = 0) >> >> #foreach ($element in $SortTool.sort($Array, ["rank", "name"])) >> #set ($mrank = $element.Rank) >> #set ($record = { 'Rank' : $element.Rank, 'Title' : $element.Name } ) >> #if ($mrank<= 30) #set ($n = $MS1.add($record)) #end >> #if ($mrank>= 60) #set ($n = $MS3.add($record)) #end >> #if ($mrank> 30&& $mrank< 60) #set ($n = $MS2.add($record)) #end >> ## #set ($n = $MS1.add($record)) ## debug, commented out >> #end >> >> Gary Catlin >> >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org > For additional commands, e-mail: user-h...@velocity.apache.org > >