How can I initialize a variable of the type TStrings?
--
CU,
Gerald
eMail............gschneider@gmx.de
Homepage...http://surf.to/phreak
ICQ99a........4910692
Pager...........9494048@scall.de
var MyStrings: TStringList;
i: Integer;
begin
MyStrings:= TStringList.Create;
try
MyStrings.Add('string1');
MyStrings.Add('string2');
MyStrings.Add('string3');
for i:=0 to MyStrings.Count-1 do
Memo1.Lines.Add(MyStrings.Strings[i]);
finally
MyStrings.Free;
end;
end;
HTH,
Shane Bridges
Gerald Schneider <gschn...@gmx.de> wrote in message
news:93414750...@news.mediaWays.net...
MultipleDrivesList := TStringList.Create;
MultipleDrivesList.Free;
Gerald Schneider wrote in message <93414750...@news.mediaWays.net>...
>>It's surely quite simple, but I always get the message: Warning: variable
>>'xxxx' has not been initialized
I haven't seen the code but it's common to get this message if the variable is
either created or 'initialised' _within_ a try finally block ie
SomeProcedure(...
var
i: integer;
begin
try
i:= 0;
//more code
finally
...
end;
end;
will produce the warning message.
SomeProcedure(...
var
i: integer;
begin
i:= 0; //moved out of try finally block
try
//more code
finally
...
end;
end;
won't.
As it's only _trying_ it, it isn't guaranteed to happen.
Gordon.
~~~~~~~~~~~~~~~~~~~~~~~~
Certifiable - definitely <g>
http://members.aol.com/mgcsoft/ (the function junction equation editor)
http://members.aol.com/delphistuf/delphstf.htm (Delphi bits and bobs and a
few links)
MGCSoft