Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Case: "Constant expression expected" mit Konstante (https://www.delphipraxis.net/66912-case-constant-expression-expected-mit-konstante.html)

Alloc 6. Apr 2006 13:00


Case: "Constant expression expected" mit Konstante
 
Hi alle,

habe hier mal wieder einen (meiner Meinung nach) ziemlich komischen Fehler. Der Compiler beschwert sich bei folgendem Code:

Delphi-Quellcode:
  const
    DataBackend_Dat:ShortInt=0;
  begin
    case backend of
      DataBackend_Dat: Exit; // <-- Constant expression expected
    end;
  end;
Irgendwelche Ideen? =)

Gruß, Chris

generic 6. Apr 2006 13:01

Re: Case: "Constant expression expected" mit Konst
 
lass mal
Zitat:

:ShortInt
weg

Die Muhkuh 6. Apr 2006 13:01

Re: Case: "Constant expression expected" mit Konst
 
Hi,

lass mal das ShortInt weg ;)

[edit] Roter Kasten, ich vermisse dich... [/edit]

Alloc 6. Apr 2006 13:05

Re: Case: "Constant expression expected" mit Konst
 
Hey, das funktioniert ja :lol: ... danke

Kann mir auch einer erklären, warum das ohne eine Typenangabe funktioniert und mit nicht? :?:

Chris

Sharky 6. Apr 2006 13:08

Re: Case: "Constant expression expected" mit Konst
 
Hai Alloc,

Case kommt mit Delphi-Referenz durchsuchenTypisierte Konstanten nicht zurecht. Du kannst aber auf einem anderen Weg den "Typ" angeben:
Delphi-Quellcode:
const
  DataBackend_Dat = Shortint(0);

Elvis 6. Apr 2006 13:26

Re: Case: "Constant expression expected" mit Konst
 
Typisierte "Konstanten" sind ja auch nicht konstant. Der Name und die Syntax ist einfach dumm gewählt. Eigentlich sind es lokale statische Variaben wie man sie von C-ish Sprachen kennt.


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