AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Customsort - sortieren nach datum

Ein Thema von Susanne · begonnen am 10. Nov 2006 · letzter Beitrag vom 25. Dez 2007
Antwort Antwort
Elvis

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

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


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz