iChallengeYou Posted January 2, 2015 Share Posted January 2, 2015 First a happy new year So I want to define a global flag which can be used everywhere in the project. So in example i want something like this: isUnpackMe = false; Button1.Click() { if (isUnpackMe) { ShowMessgae('This is an unpackme'); } } So i don't want to declare isUnpackMe as an variabele but want to define it like the pre-defined {$IFDEF CPUX86}. Does anyone know how to do that? Link to comment
Kurapica Posted January 2, 2015 Share Posted January 2, 2015 http://stackoverflow.com/questions/5774598/declare-public-global-variable-in-delphi Link to comment
mrexodia Posted January 2, 2015 Share Posted January 2, 2015 I think this is what you mean:var text : string;begin // Set our code into test mode {$Define TESTMODE} text := 'We are in test mode'; // Display the value of text if we are in test mode {$IfDef TESTMODE} ShowMessage('text = '+text); {$EndIf} // Switch off test mode {$UnDef TESTMODE} text := 'We are out of test mode'; // Display the value of text if we are in test mode {$IfDef TESTMODE} ShowMessage('text = '+text); {$EndIf}end;Source:http://www.delphibasics.co.uk/RTL.asp?Name=$Define 1 Link to comment
iChallengeYou Posted January 2, 2015 Author Share Posted January 2, 2015 Exactly! Thanks Mr.exodia Link to comment
simple Posted January 4, 2015 Share Posted January 4, 2015 You can also use M4 macros for a bit more functionality. Always wondered why Delphi has no preprocessor.. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now