Solved

TList sort

Posted on 1998-09-03
7
166 Views
Last Modified: 2010-04-04
hi
 

i have class that one of his member are FList
i"m tring to do sort on it.
for some reason when ever i"m execute the sort operation , the data(i.e/ the function params ) that come
to that function ListSortByTafkidEruaDate(Item1, Item2: Pointer): Integer;
is not correct and some exception rais up with some adress access Error
its look like when the program come to that function it lost the pointer to the class that contain that function , because any try to access that class member property cause and Err

any one have ide
10x in advance
asi
0
Comment
Question by:asi
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1338541
Would you please write down only your compare function?
Igor
0
 

Author Comment

by:asi
ID: 1338542
i wrote 2 function ,both of them are important (as far as i know)
10x again
Asi

procedure TItemsIrg.SortByTafkidEruaDate;
var
  TempSortCompare: TListSortComp;
begin
  TempSortCompare := ListSortByTafkidEruaDate;
  FList.SORT(TListSortCompare(TempSortCompare));
end;


function TItemsIrg.ListSortByTafkidEruaDate(Item1, Item2: Pointer): Integer;
var
  ItemIrg1 , ItemIrg2 : TItemIrg;

begin
  ItemIrg1:=TItemIrg(Item1);
  ItemIrg2:=TItemIrg(Item2);
  result :=ItemIrg1.tafkid - ItemIrg2.tafkid;
  if result=0 then
  begin
    result := ItemIrg1.Erua - ItemIrg2.Erua;
    if result=0 then
      Result := Trunc(ItemIrg1.DtDate - ItemIrg2.DtDate);
  end;
end;

0
 
LVL 5

Expert Comment

by:inter
ID: 1338543
Make the following changes

Comment
      From: asi
                                                   Date: Thursday, September 03 1998 - 09:45AM PDT

      i wrote 2 function ,both of them are important (as far as i know)
      10x again
      Asi

//*** do not make this object function
      function ListSortByTafkidEruaDate(Item1, Item2: Pointer): Integer;
      var
        ItemIrg1 , ItemIrg2 : TItemIrg;
      begin
        ItemIrg1:=TItemIrg(Item1);
        ItemIrg2:=TItemIrg(Item2);
        result :=ItemIrg1.tafkid - ItemIrg2.tafkid;
        if result=0 then
        begin
          result := ItemIrg1.Erua - ItemIrg2.Erua;
          if result=0 then
            Result := Trunc(ItemIrg1.DtDate - ItemIrg2.DtDate);
        end;
      end;

      procedure TItemsIrg.SortByTafkidEruaDate;
      var
        TempSortCompare: TListSortComp;
      begin
        TempSortCompare := ListSortByTafkidEruaDate;
// do not typecast just give function name
//        FList.SORT(TListSortCompare(TempSortCompare));
        FList.SORT(ListSortByTafkidEruaDate);
      end;


0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:asi
ID: 1338544
hey inter !

your answer is under Comment subject
please cut & paste it AS ANSWER so i can give u the points

10x
Asi
0
 
LVL 5

Accepted Solution

by:
inter earned 20 total points
ID: 1338545
Thanks, and c.u.(I suppose it works ;-)

//*** do not make this object function
            function ListSortByTafkidEruaDate(Item1, Item2: Pointer): Integer;
            var
              ItemIrg1 , ItemIrg2 : TItemIrg;
            begin
              ItemIrg1:=TItemIrg(Item1);
              ItemIrg2:=TItemIrg(Item2);
              result :=ItemIrg1.tafkid - ItemIrg2.tafkid;
              if result=0 then
              begin
                result := ItemIrg1.Erua - ItemIrg2.Erua;
                if result=0 then
                  Result := Trunc(ItemIrg1.DtDate - ItemIrg2.DtDate);
              end;
            end;

            procedure TItemsIrg.SortByTafkidEruaDate;
            var
              TempSortCompare: TListSortComp;
            begin
              TempSortCompare := ListSortByTafkidEruaDate;
      // do not typecast just give function name
      //        FList.SORT(TListSortCompare(TempSortCompare));
              FList.SORT(ListSortByTafkidEruaDate);
            end;

Regards, Igor
0
 

Author Comment

by:asi
ID: 1338546
yap

thats work

may i ask where r u from ?
Asi
b_asi@inter.net.il
0
 
LVL 5

Expert Comment

by:inter
ID: 1338547
I am from turkey,
inter@kosgeb.tekmer.gov.tr
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now