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