Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   XML (https://www.delphipraxis.net/46-xml/)
-   -   Delphi Woher weiß ich, von welchem Typ meine XML-Inhalte sind? (https://www.delphipraxis.net/176055-woher-weiss-ich-von-welchem-typ-meine-xml-inhalte-sind.html)

Furtbichler 10. Aug 2013 13:38

AW: Woher weiß ich, von welchem Typ meine XML-Inhalte sind?
 
Das ist doch in nullkommanix runtergetippt

Delphi-Quellcode:
If TryCastAsBoolean(myValue) then
  Return 'Boolean'
else if TryStrToInt(myValue, someInteger) then
  Return 'Integer'
else if TryStrToFloat(myValue, someFloat) then
  Return 'Double'
else if TryStrToDateTime(myValue, someDateTime) then
  Return 'DateTime'
else
  Return 'String';
Kompiliert so vermutlich nicht, aber der Sinn sollte klar sein: Einfach durchprobieren.

mjustin 11. Aug 2013 10:54

AW: Woher weiß ich, von welchem Typ meine XML-Inhalte sind?
 
Zitat:

Zitat von Furtbichler (Beitrag 1224258)
Das ist doch in nullkommanix runtergetippt

Delphi-Quellcode:
...
else if TryStrToFloat(myValue, someFloat) then
...

Den overload mit const FormatSettings: TFormatSettings zu benutzen wäre nicht verkehrt, '100,000' und '100.000' sind sonst leicht zu verwechseln ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:36 Uhr.
Seite 2 von 2     12   

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