AGB  ·  Datenschutz  ·  Impressum  







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

Bedingt Prozedur aufrufen

Ein Thema von CRoSSi · begonnen am 24. Jan 2008 · letzter Beitrag vom 1. Feb 2008
Antwort Antwort
Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.779 Beiträge
 
Delphi 10.4 Sydney
 
#1

Re: Bedingt Prozedur aufrufen

  Alt 24. Jan 2008, 09:33
Guten Morgen,

vielleicht kannst Du mit defines arbeiten:

Zitat von DelphiHilfe:
Type Conditional compilation
Syntax {$IF expression}
Remarks

Compiles the source code that follows it if expression is True. expression must conform to Object Pascal syntax and return a Boolean value; it may contain declared constants, constant expressions, and the functions Defined and Declared.
For example,

{$DEFINE CLX}

const LibVersion = 2.1;

{$IF Defined(CLX) and (LibVersion > 2.0) }
... // this code executes
{$ELSE}
... // this code doesn't execute

{$IFEND}

{$IF Defined(CLX) }
... // this code executes
{$ELSEIF LibVersion > 2.0}
... // this code doesn't execute
{$ELSEIF LibVersion = 2.0}
... // this code doesn't execute
{$ELSE}
... // this code doesn't execute
{$IFEND}

The special functions Defined and Declared are available only within $IF and $ELSEIF blocks. Defined returns True if the argument passed to it is a defined conditional symbol. Declared returns True if the argument passed to it is a valid declared Pascal identifier visible within the current scope.

The $IF and $ELSEIF directives are terminated with $IFEND, unlike other conditional directives that use the $ENDIF terminator. This allows you to hide $IF blocks from earlier versions of the compiler (which do not support $IF or $ELSEIF) by nesting them within old-style $IFDEF blocks. For example, the following construction would not cause a compilation error:

{$UNDEF NewEdition}

{$IFDEF NewEdition}
{$IF LibVersion > 2.0}
...
{$IFEND}
{$ENDIF}

$IF supports evaluation of typed constants, but the compiler doesn't allow typed constants within constant expressions. As a result,

const Test: Integer = 5;

{$IF SizeOf(Test) > 2}

...

is valid, while

const Test: Integer = 5;

{$IF Test > 2 } // error

...

generates a compilation error.

If your code needs to be portable between various versions of Delphi (as well as Kylix), you will need to test whether or not this directive is supported by the compiler. You can surround your code with the following directives:

$IFDEF conditionalexpressions

. // code including IF directive
. // only executes if supported
$ENDIF
Klaus
  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 05:01 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