[Zope] comparing two variables type="int"

Charlie Reiman creiman@kefta.com
Tue, 18 Jun 2002 09:47:11 -0700


Be more specific. How is it failing? Do you get a runtime error or are
things just not evaluating the way you expect?

In either case, try:

<dtml-if expr="int(A)==int(B)">
blargh
</dtml-if>

Just because you think it's an int, doesn't mean it is an int.

There is also the possibility that "A" and "B" are not available directly in
python (assuming the real variables you are trying to access are not "A" and
"B"). This is a common DTML problem since lots of DTML vars have "-" in
their names, which will confuse python.

So you would do this:

<dtml-if expr="int(_['A'])==int(_['B'])">
blech
</dtml-if>



> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Mike
> Tran
> Sent: Tuesday, June 18, 2002 7:54 AM
> To: zope@zope.org
> Subject: [Zope] comparing two variables type="int"
>
>
> Hi,
>
> I have two variables A & B whose types are "int".  What is wrong
> with this
> comparision?
>
> (Assume A=5 and B=5)
>
> <dtml-if "A==B">
> Then do something
> </dtml-if>
>
> I've have also tried.
>
> <dtml-if expr="A==B">
> Then do something
> </dtml-if>
>
> None of these above work.
> This works fine when A & B are of types string instead of intergers.
> Thanks for any suggestions.
>
> --
>
> Mike.
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>