I am trying to implement System.Collections.IComparer in Progress 4gl.
With the following code, I get the error: Incompatible data types in expression or assignement. (223)
CLASS Tools.Comparer.ItemByItemNo IMPLEMENTS System.Collections.IComparer:
METHOD PUBLIC INTEGER Compare(
INPUT o1 AS System.Object
,INPUT o2 AS System.Object):
/* declaration */
DEFINE VARIABLE oItem1 AS Entity.Item NO-UNDO.
DEFINE VARIABLE oItem2 AS Entity.Item NO-UNDO.
/* cast */
ASSIGN oItem1 = CAST(o1, "Entity.Item").
ASSIGN oItem2 = CAST(o2, "Entity.Item").
/* compare */
RETURN Tools.String:Compare(oItem1:ItemNo, oItem2:ItemNo).
END METHOD.
END CLASS.
Is it possible to cast a class from System.Object?
Thank you! Sebastien
/* Here the code of compare to mimic the .NET compare in progress */
METHOD STATIC PUBLIC INTEGER Compare(
INPUT String1 AS CHARACTER
,INPUT String2 AS CHARACTER):
IF string1 < string2 THEN
RETURN -1.
ELSE IF string1 = string2 THEN
RETURN 0.
ELSE IF string1 > string2 THEN
RETURN 1.
END METHOD.