Question regarding the IF node

15 views
Skip to first unread message

Smartelf

unread,
Aug 29, 2012, 7:01:35 PM8/29/12
to excelt...@googlegroups.com
Hi,

I need a cell to display one of 3 possible values, based on a global variable. However, none of my if conditions are being used?

Code below:

Thanks in advance,

--Smartelf

lets say my xml looks like this:
<loop name="loop1">
    <loop name="loop2">
        <if name="myGlobal" value="0">
            <cell text="A">
            <cell text="$i" />
        </if>
        <if name="myGlobal" value="1">
            <cell text="B">
            <cell text="$i" />
        </if>
        <if name="myGlobal" value="2">
            <cell text="C">
            <cell text="$i" />
        </if>
     </loop>
</loop>

and my perl code looks as following:

my $hash;
foreach my $i (0..10){
    foreach my $j(0..10){
        $hash{loop1}[$i]{loop2}[$j]{i} = $i * $j;
    }
}
$hash{myGlobal}=1;

...

$template->param(%hash);

Eugene Flitman

unread,
Aug 30, 2012, 7:19:12 AM8/30/12
to Smartelf
Hi,

I am not sure if globals are accessible within loops, because related modules behave differently: 
HTML::Template (quite stable) - supports globals in loops, but whether it actually sees them is controlled by a parameter.
PDF::Template (quirky) - cannot see globals within loops (though should, it is a bug).

You should test this - try to use ifs with local variables in loops instead of a global and see if it works.

This also may be a bug in Excel::Template. I've used only 'is' attribute with 'if', it works. However, I don't know whether 'value' works as well.

EF





-- 
You received this message because you are subscribed to the Google Groups "Excel::Template" group.
To view this discussion on the web visit https://groups.google.com/d/msg/exceltemplate/-/_xjxffDAEAIJ.
To post to this group, send email to excelt...@googlegroups.com.
To unsubscribe from this group, send email to exceltemplat...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exceltemplate?hl=en.


Smartelf

unread,
Aug 30, 2012, 10:41:07 AM8/30/12
to excelt...@googlegroups.com
Thanks,

By making it local, it did work. I just wish that global parameters would be allowed. I wonder if a global node can be created.

thanks,

--Smartelf
Reply all
Reply to author
Forward
0 new messages