Error in an inequality

Bug reports and feature requests. New features can only be added to the current development version. Bug-fixes may be back-ported.

Current release: 099 / Current development: 100
Post Reply
Korbedda
New User
Posts: 8
Joined: Wed Mar 14, 2012 4:05 pm

Error in an inequality

Post by Korbedda »

Hi, if I compare an error with a number (SendSysMessage(me, CStr(error < 1))), the result is random, sometimes 0 and sometimes 1. I would expect the result to be an error or zero.
kevin
POL Developer
Posts: 53
Joined: Wed Sep 29, 2010 3:47 pm
Contact:

Re: Error in an inequality

Post by kevin »

Looks like error and struct both do not have operators defined for those arithmetic operations (<, <=, >, >=, etc) so they only compare the memory addresses of those variables, which would make sense for your "randomness".

From a brief glance at the code:

x < y:
If x is Long:
--- If y is Long or Double, then return the normal expected value of numeric x < numeric y.
--- Otherwise, ALWAYS return false.
If x is Error (or Struct, or any other object that does not have isLessThan defined):
--- Return memory address location of x < memory address location of y => unknown results
Korbedda
New User
Posts: 8
Joined: Wed Mar 14, 2012 4:05 pm

Re: Error in an inequality

Post by Korbedda »

Okay, thanks, here's why I think it should be fixed. In eScript many error catches are done by error propagation, like in this case:

Code: Select all

if (GetSomething(someone).getprop(some true/false parameter))
    do something
endif
If there is something wrong with the input, something doesn't exist, the result is an error. So you just write the condition and if there's anything wrong on the way, you expect the result to return an error. It allows for more compact code by putting multiple error checks together. It is used quite often and I came to rely on this, as many other may have. It just doesn't work for inequalities. That is why I am pointing this out.
Post Reply