Delphi doesn’t have the concept of static function variables as you find in languages like C++. However, it is still possible to achieve the same behavior via a compiler directive.
Consider this simple example:
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
procedure Enter;
{$J+}
const
Count: Integer = 0;
begin
Inc(Count);
WriteLn('Entered ' + Count.ToString + ' times');
end;
begin
Enter;
Enter;
Enter;
end.
// output
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.
For more information on compiler directions, see here.