![]() |
Frage zu GetEnumValue
Hallo,
hier mal ein Beispiel um meine Frage verständlicher zu machen:
Delphi-Quellcode:
Mein Problem liegt jetzt darin, wenn x weder mtA, noch mtB oder mtC ist. Wenn ich Debugge steht da:
type
TMeinTyp = (mtA, mtB, mtC); procedure bla(x: string); var hilf: TMeinTyp; begin hilf := TMeinTyp(GetEnumValue(TypeInfo(TMeinTyp), x)); ... end;
Code:
Wie kann ich jetzt abfragen ob das nun -1 ist.
hilf = (out of bound) -1
Delphi-Quellcode:
funktioniert nicht, da -1 nicht vom Typ TMeinTyp ist? Der einzige wichtige Fall ist aber, wenn hilf = -1.
if hilf = -1 then
mfg Niels |
Re: Frage zu GetEnumValue
Was steht denn in x drin?
|
Re: Frage zu GetEnumValue
Zitat:
proviers mal so ;)
Delphi-Quellcode:
mfG
procedure bla(const x: string);
var hilf: Integer; wert: TMeinTyp; begin hilf := GetEnumValue(TypeInfo(TMeinTyp), x); if hilf = -1 then ... else wert := TMeinTyp(hilf); end; mirage228 |
Re: Frage zu GetEnumValue
Hi,
danke ...funktioniert prima. Hätte ich eigentlich auch selbst drauf kommen können :duck: mfg Niels |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:12 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz