Re:Help with TStringList (Second Request)
In article <01bbe761$c1239840$b2362...@shae.together.net>,
"Kathleen MacMahon" <s...@together.net> wrote:
]-
]-I would like to create a TStringList that contains values read in from a
]-Section of an INI file. I have followed the examples in the help file but
]-I keep getting nothing but an Access Violation. The TStringlist should be
]-available to all my forms/procedures.
]-
]-I've managed to accomplish this much:
]-Var
]-IniFile: TIniFile;
]-begin
]-Inifile := Tinifile.Create('Simple.ini');
]-Inifile.ReadSection('Sites', ListBox1.Items);
]-Inifile.ReadSectionValues('Sites', Listbox2.Items);
]-IniFile.Free;
]-end;
]-
]-I have tried the following: (Where SiteList is a TStringlist)
]-
]-Inifile.ReadSection('Sites',SiteList);
]-Or
]-SiteList.Assign(ListBox1.Items);
]-Or
]-SiteList.AddStrings(ListBox1.Items);
]-
]-I cannot get any of these to work. Help would be appreciated. Also, WHERE
]-should the declaration for SiteList be if I want access to it anywhere in
]-my program.
double check your spelling, and the path to your ini file. when I tried
to reproduce your problem I "succeeded" fabulously -- every call to
ReadSection returned an empty list. after a bit of thrashing around though,
I eventually noticed that I'd made a typo in writing the name of my .ini
file. after fixing the typo I was able to use ReadSection to load a list
box, and a string list.
as far as where to declare SiteList...how many different units need visibility
to it? if only one, then declare SiteList as a variable in the implementation
section of that unit. if more than one, declare it in the interface section of
a unit that's used in common by all of the units that reference SiteList. if
you don't have a unit that's already used by all of the units that need to see
SiteList, you can always make one.
Mark Vaughan