Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi TFormatsettings etc unter Delphi 6 ? (https://www.delphipraxis.net/196835-tformatsettings-etc-unter-delphi-6-a.html)

myicq 24. Jun 2018 07:51

TFormatsettings etc unter Delphi 6 ?
 
Gibt es eine Implementation für GetLocaleFormatSettings und TFormatsettings für Delphi 6 ?

KodeZwerg 24. Jun 2018 08:20

AW: TFormatsettings etc unter Delphi 6 ?
 
Da ich Deinen Source nicht kenne gebe ich Dir das mit auf den Weg.
Beispiel:
Delphi-Quellcode:
function StringToDateTime(const Value: String): TDateTime;
var
  FormatSettings: TFormatSettings;
begin
  GetLocaleFormatSettings(LOCALE_USER_DEFAULT, FormatSettings);
  FormatSettings.DateSeparator := '_';
  FormatSettings.ShortDateFormat := 'dd_mm_yyyy_hh_nn_ss';
  Result := StrToDateTime(Value, FormatSettings);
end;
könnte man mit Delphi 6 so machen: (quickanddirty)
Delphi-Quellcode:
function StringToDateTime(const Value: String): TDateTime;
var ds, sdf: Ansistring;
begin
  ds := DateSeparator;
  sdf := ShortDateFormat;
   try
    DateSeparator := '_';
    ShortDateFormat := 'dd_mm_yyyy_hh_nn_ss';
    Result := StrToDateTime(Value);
  finally
    DateSeparator := ds;
    ShortDateFormat := sdf;
  end;
end;
Hilft Dir das weiter?

Bernhard Geyer 24. Jun 2018 21:15

AW: TFormatsettings etc unter Delphi 6 ?
 
Zitat:

Zitat von myicq (Beitrag 1405659)
Gibt es eine Implementation für GetLocaleFormatSettings und TFormatsettings für Delphi 6 ?

Unter D6 waren die Properties von TFormatsettings noch globale Variablen. Such mal danach in welcher Unit die sich damals verborgen hatten.

myicq 24. Jun 2018 21:45

AW: TFormatsettings etc unter Delphi 6 ?
 
Sorry, ich hatte zu wenig Zeit das richtig zu fragen:

ich möchte gern die richtige Implementation von TformatSettings haben. Ich habe das unit Sysutil aus Delphi 7 geholt, aber leider kann ich das nicht (angeblich) direkt benutzen, ich bekomme eine Fehler in eine deklaration:

Delphi-Quellcode:

  Exception = class(TObject)
  private
    FMessage: string;
    FHelpContext: Integer;
    FInnerException: Exception;
    FStackInfo: Pointer;
    FAcquireInnerException: Boolean;
    class constructor Create;         // <<< Fehler: "[Error]: PROCEDURE or FUNCTION expected
    ...
gibt es bei D6 keine "Class Constructor Create" ?


Btw: ich weiss wie ich die Funktionen umgehe, mit "custom" date/time-funktionen, aber immerhin.. es währe schön wenn ich andere Units nicht umschreiben musste.

jaenicke 24. Jun 2018 22:06

AW: TFormatsettings etc unter Delphi 6 ?
 
Zitat:

Zitat von myicq (Beitrag 1405690)
gibt es bei D6 keine "Class Constructor Create" ?

Nein, da gab es für den Zweck nur die initalization Sektion für die ganze Unit, die man für den Zweck nutzen kann. Klassenkonstruktoren kamen soweit ich mich erinnere erst mit Delphi 2010.

Zitat:

Zitat von myicq (Beitrag 1405690)
Ich habe das unit Sysutil aus Delphi 7 geholt, aber leider kann ich das nicht (angeblich) direkt benutzen

So etwas funktioniert auch nicht. Ganz abgesehen von neuen Sprachfeatures usw. werden Units wie diese auch von anderen Units aus der Delphi RTL verwendet. Dadurch bekommst du dann Meldungen nach dem Motto "Unit XY wurde mit einer anderen Version von SysUtils kompiliert" usw.

Wenn man bei alten Delphiversionen bleiben möchte, sollte man sich auch auf die dort zur Verfügung stehenden Features beschränken. Oder eben alternativ neue Delphiversionen einsetzen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:16 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