BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TList sorting again ...

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Thu Mar 30, 2006 11:04 pm    Post subject: TList sorting again ... Reply with quote



I am trying to get a TList sort working. I have declared a compare
function as

function CompareElementName(AP1, AP2: Pointer): integer;
begin
Result:=AnsiCompareStr(TMyObject(AP1).Name,TMyObject(AP2).Name);
end;

and assign it to the TList's sort method with:

procedure TBSCADBaseElementList.SortElements;
begin
Self.fElementsList.Sort(CompareElementName); //Line 3612
end;

The problem is that like this the compiler complains with the error:

[Error] unBSCADObjects.pas(3612): Incompatible types: 'Pointer' and
'_Pointer'

If I put in a "@", like this:

procedure TBSCADBaseElementList.SortElements;
begin
Self.fElementsList.Sort(@CompareElementName); //Line 3612
end;

The compiler is happy, but at runtime when Quicksort calls my compare
function I get:

exception class EAccessViolation with message 'Access violation at
address 00404634 in module 'MyApp.exe'. Write of address 005167FC'.

As far as I can tell it can't get to my object members.

Can anyone save me some anguish?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.