Hi All!

Is there any way to pass a method function as the Compare parameter to a TList or is there a work around for it?

There are generics involved so it won't let me access the static symbol table.

As in:

type
  TMyClass = object
     fIndex : Integer;
     List : array of TList;
function Compare( Item1, Item2 : Pointer) : Longint; // needs access to fIndex

     procedure Sort;
  end;

implementation

function TMyClass.Compare( Item1, Item2 : Pointer ) : Longint;
begin
   case fIndex of
0: Result := some compare of Item1, Item2;// These compares are implemented in an object from another unit
      1:  Result := another compare of Item1, Item2
   end;
end;

procedure TMyClass.Sort;
begin
  fIndex := 0;

List[fIndex].Sort( @Compare ); // Compilation error, doesn't like Compare being "of object"

end;


Thanks,

Don Ziesig


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to