On 25.04.2011 15:57, Marco van de Voort wrote:
On Mon, Apr 25, 2011 at 10:15:57AM +0200, Hans-Peter Diettrich wrote:
(without specifically assigning it to NIL in the declaration)
var
slTest :TStringList;
begin
if Assigned(slTest) then FreeAndNil(slTest); // gives exception
end;
When slTest is a local variable, you should initialize it to Nil.
Just to be clear
Initialize it in code not in the declaration, since in the declaration afaik
that makes it a static variable instead of a truely local one, even when
declared
with local scope.
You can only initialize a global variable. For "initialized local
variables" you need to use writable "constants" ;)
Regardts,
Sven
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus