Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TList sort

Posted on 1998-09-03
7
Medium Priority
?
171 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
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!

 

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 80 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

688 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