Solved

TList sort

Posted on 1998-09-03
7
164 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

23 Experts available now in Live!

Get 1:1 Help Now