1 is greater then 2 ?!?
I'm trying to schedule some events based on dates, and not really having much luck. My problem comes from a <gt> comparison. Earlier today I was getting that 0 was not greater then -29, now I'm getting that 1 is greater then 2! Can anyone shed some light on what is happening?
Here is the trace of my questionable code....
<cond>
<gt>
<ref>daysAllowedForAccess</ref> --> 1
<ref>daysUntilAffiliation</ref> --> 2
</gt> --> 1
[524 byte] By [
JimBearda] at [2007-11-26 14:52:57]

# 1
Hi,
I created a simple rule to test this:
<Rule name='New Rule'>
<cond>
<gt>
<ref>daysAllowedForAccess</ref>
<ref>daysUntilAffiliation</ref>
</gt>
<s>daysAllowedForAccess</s>
<s>daysUntilAffiliation</s>
</cond>
</Rule>
Following is the trace and the results are coming just fine as expected:
<Rule name='New Rule'>
<cond>
<gt>
<ref>daysAllowedForAccess</ref> --> 1
<ref>daysUntilAffiliation</ref> --> 2
</gt> --> 0
<s>daysUntilAffiliation</s> --> daysUntilAffiliation
</cond> --> daysUntilAffiliation
</Rule> --> daysUntilAffiliation
<Rule name='New Rule'>
<cond>
<gt>
<ref>daysAllowedForAccess</ref> --> 0
<ref>daysUntilAffiliation</ref> --> -29
</gt> --> 1
<s>daysAllowedForAccess</s> --> daysAllowedForAccess
</cond> --> daysAllowedForAccess
</Rule> --> daysAllowedForAccess
Regards,
Hemant
# 3
I believe it has to do with variable types. xpress is loosly typed and does not enforce any strict data types. Through trial and error, I figured out that I was comparing an xpress int (<i>30</i>, or whatnot) with a primitive java long variable type that was being returned through an invoke method. I subsequently changed my code to reflect,
<gt>
<mult>
<ref>daysAllowedForAccess</ref>
<i>1</i>
</mult>
<invoke name='parseInt' class='java.lang.Integer'>
<invoke name='toString' class='java.lang.Long'>
<ref>daysUntilAffiliation</ref>
</invoke>
</invoke>
</gt>
and now its working fine. I bit of a work around it seems....