Einzelnen Beitrag anzeigen

Elvis

Registriert seit: 25. Nov 2005
Ort: München
1.909 Beiträge
 
Delphi 2010 Professional
 
#7

Re: Customsort - sortieren nach datum

  Alt 10. Nov 2006, 10:12
Zitat von Susanne:
auch nicht
Bei mir gates schon, auch ohne "@".
Delphi-Quellcode:
{$APPTYPE CONSOLE}

uses
  SysUtils,
  Classes,
  DateUtils;

function CompareDate(List: TStringList; Index1, Index2: Integer): Integer;
var
  Val1, Val2: TDateTime;
begin
  val1:= FileDateToDateTime(FileAge(list[Index1]));
  val2:= FileDateToDateTime(FileAge(list[Index2]));
  Result := CompareDateTime(Val1, Val2);
end;

var
  sl : TStringList;
  i : Integer;
begin
  sl := TStringList.Create();

  sl.Add('New Text Document (3).txt');
  sl.Add('New Text Document (2).txt');
  sl.Add('New Text Document.txt');

  sl.CustomSort(CompareDate);

  for i := 0 to sl.Count - 1 do
  begin
    Writeln(sl[i]);
  end;
end.

Zitat von oki:
P.S. hinder Functionsdeklaration stcll; !!
Nein, TStringListSortCompare ist nicht als stdcall deklariert. Somit wird die normale Delphi Calling convention erwartet. (register)
Robert Giesecke
I’m a great believer in “Occam’s Razor,” the principle which says:
“If you say something complicated, I’ll slit your throat.”
  Mit Zitat antworten Zitat