Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

(Delphi) Define global flag?

Featured Replies

Posted

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?


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

  • Author

Exactly! Thanks Mr.exodia :)


You can also use M4 macros for a bit more functionality. Always wondered why Delphi has no preprocessor..  :scratch:


Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.