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.
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 )
Mike Tran writes:
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> It is nothing wrong. It must work!
But DTML is dangerous. Sometimes, you do not get the objects you expect. I expect that this is your true problem. Dieter
Try <dtml-if expr="A == B"> Dieter Maurer wrote:
Mike Tran writes:
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> It is nothing wrong. It must work!
But DTML is dangerous.
Sometimes, you do not get the objects you expect. I expect that this is your true problem.
Dieter
_______________________________________________ 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 )
participants (4)
-
Charlie Reiman -
Dieter Maurer -
Michael -
Mike Tran