The Compiler Directive

Delphi doesn't have the concept of static local variables as you find in languages like C++. However, it is still possible to achieve the same behavior via a compiler directive:

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

procedure Enter;
{$J+}
const
  Count: Integer = 0;
{$J-}
begin
  Inc(Count);
  WriteLn('Entered ' + Count.ToString + ' times');
end;

begin
  Enter;
  Enter;
  Enter;
end.

// Entered 1 times
// Entered 2 times
// Entered 3 times

The {$J+} directive instructs the compiler to allow the constant to be written to, as described here.

Please note, this is not inherently thread-safe.

For more information on compiler directives, see here.