Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TList sort

Posted on 1998-09-03
7
Medium Priority
?
174 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

773 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