Solved

TList sort

Posted on 1998-09-03
7
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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