Compare(x: Variant; y: Variant): Integer;
x. Object that should be compared.
y. Object, with which it is required to compare.
The Compare method compares objects passed as input parameters and returns comparison result.
The method returns the following values:
0 - if objects are equal.
1 - if value of X is greater than value of Y.
-1 - if value of X is less than value of Y.
If the Compare method is redetermined in the application class, the method can return any values.
Add a link to the Math system assembly.
Sub UserProc;
Var
Comp: IComparer;
x, y: DateTime;
i, Year, Month, Day: Integer;
Begin
Day := Math.RandBetweenI(1, 31);
Month := Math.RandBetweenI(1, 12);
Year := Math.RandBetweenI(2000, 2020);
x := DateTime.Today;
y := DateTime.ComposeDay(Year, Month, Day);
Comp := Comparer.DateTimeComparer;
i := Comp.Compare(x, y);
End Sub UserProc;
After executing the example the "i" variable contains the result of comparison of the current date and the other one generated in random way.
See also: