Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-09

does FPC support static variable inside a procedure ?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

Is there a way to create a static variable inside a procedure ? The following code:

procedure static_variable;
var static_var : Integer = -1;
begin
  inc(static_var);
  writeln('static_var ', static_var);
end;
begin
  while true do
    begin
      static_variable;
      sleep(1000);
    end;
end.

Always print "0" as the answer.

Ido

Reply by email

Martin
to ik
ik wrote 7 lines
Hello, Is there a way to create a static variable inside a procedure ? The following code: procedure static_variable; var static_var : Integer = -1;
const
   static_var: integer = 1;
Show quoted text 5 lines
begin inc(static_var); writeln('static_var ', static_var); end;

Reply by email