Hi,
Currently you can write the following code:
CLASS MyClass:
DEFINE PUBLIC PROPERTY Value AS INTEGER NO-UNDO
GET.
SET.
END CLASS.
/****************************************************/
DEFINE VARIABLE MyFirstObject AS MyClass NO-UNDO.
DEFINE VARIABLE MySecondObject AS MyClass NO-UNDO.
MyFirstObject = NEW MyClass().
MySecondObject = NEW MyClass().
MyFirstObject:Value = 2.
MySecondObject:Value = 1.
MESSAGE MyFirstObject < MySecondObject SKIP
MyFirstObject:Value < MySecondObject:Value
VIEW-AS ALERT-BOX.
While this code compiles, it is useless as you can't influence how the < or > operators are interpreted.
The first created object seems to be always less than the second created one, which leads me to believe that the internal handle value gets compared.
There should be a way to influence this, e.g. by implementing a IComparable interface like in c#
https://msdn.microsoft.com/en-us/library/system.icomparable(v=vs.110).aspx
Or am I missing something and is this possible in ABL?
Besides implementing the IComparable interface by creating a CompareTo() method, this would still need some form of operator overloading to make this actually work using the < or > operators...
I've added an idea community.progress.com/.../operator_overloading
Using a class variable reference w/out citing a method defaults to the "tostring" method.
Override that method and you can get this to work.
The MESSAGE statement is sometimes a little bit special in how it treats / converts things.
Try replacing
MyFirstObject < MySecondObject
with
INT64(MyFirstObject) < INT64(MySecondObject)
or even messaging those INT64() values and seeing what you get.
Again, ENUM types do NOT follow this rule ... the INT64() function will return the enumeration's value (not an "object reference id").
We have objects that mimic Enums (before the Enum functionality was introduced in the language) and with more properties than an Enum (Name, Value, ShortLabel, LongLabel, UntranslatedShortLabel, UntranslatedLongLabel).
We have implemented ToString() to return the Name of the object, whereas we would logically sort on the Value, so changing ToString isn't feasible...