<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">El 20/07/2017 a las 15:50, Sven Barth
via fpc-pascal escribió:<br>
</div>
<blockquote type="cite"
cite="mid:CAFMUeB9vGWgfkSX4R+E9F3wAne9dxLWbSVA6bMgM3eP21rQr1A@mail.gmail.com">
<p>Am 20.07.2017 13:01 schrieb "Bo Berglund" <<a
href="mailto:bo.berglund@gmail.com" moz-do-not-send="true">bo.berglund@gmail.com</a>>:<br>
><br>
> On Thu, 20 Jul 2017 11:11:50 +0200, Maciej Izak<br>
> <<a href="mailto:hnb.code@gmail.com"
moz-do-not-send="true">hnb.code@gmail.com</a>> wrote:<br>
><br>
> >2017-07-20 11:03 GMT+02:00 Bo Berglund <<a
href="mailto:bo.berglund@gmail.com" moz-do-not-send="true">bo.berglund@gmail.com</a>>:<br>
> ><br>
> >> So since I don't really want to use a global, is
it possible to<br>
> >> declare a local variable static in the sense that
it retains its<br>
> >> values across calls to the procedure?<br>
> >> If so how is it done?<br>
> >><br>
> ><br>
> >procedure foo;<br>
> >{$PUSH}<br>
> >const{$J+}<br>
> > s : string ='';<br>
> >{$POP}<br>
><br>
> Thanks,<br>
> but it looks a bit involved, probably better to use an
object field<br>
> variable instead only accessible from the internal methods.</p>
<p>If you don't want to use $push/$pop then you can also simply
enable $J+ for the whole unit. But this will also mean that
global constants are writable.</p>
</blockquote>
Well, I'm an old dog so I prefer old fashion ways. A variable that
retains its value is, from memory point of view, a global variable.
I mean, the memory is never freed, it's not freed when it goes out
of scope. So, the problem is what to do to limit the visibility to
the procedure.<br>
<br>
What about the old interface/implementation ways? You can't limit
the visibility to the procedure, but you can limit the visibility to
the implementation, so it is globally invisible.<br>
<br>
<pre>unit hiddenVar;
interface
procedure foo;
procedure resetFoo;
implementation
var
HiddenValue:integer;
procedure foo;
begin
writeln(HiddenValue);
inc(HiddenValue);
end;
procedure resetFoo;
begin
HiddenValue:=0;
end;
initialization
resetFoo;
end.</pre>
<br>
<pre class="moz-signature" cols="72">--
Saludos
Santiago A.
</pre>
</body>
</html>