Board index » delphi » TStringList Key/Value Pair

TStringList Key/Value Pair

Sorry for the simple question but how would one implement a name/value pair
in a TStringList;

I have a function that accepts a TStringList and then it uses the Name
property to locate a value;

for i:=0 to Params.Count do
begin

  if Params[i].Name = 'Content1' then
  begin
    xxx := Params[i].Values;
    break;
  end;

end;

 

Re:TStringList Key/Value Pair


Faadiel Rehman" <freh...@santanatech.com> wrote in
news:3b0fcfb4$1_2@dnews:

Quote
> Sorry for the simple question but how would one implement a
> name/value pair in a TStringList;

> I have a function that accepts a TStringList and then it uses the
> Name property to locate a value;

> for i:=0 to Params.Count do
> begin

>   if Params[i].Name = 'Content1' then
>   begin
>     xxx := Params[i].Values;
>     break;
>   end;

> end;

Faadiel,

Look in the help file under TStrings.Names, TStrings.Values and
TStrings.IndexOfName.

Basically, if the name/value pairs in your stringlist have the format
name=value, then the following code will retrieve a value for a given
name:

  MyValue := Params.Values['Content1'];

HTH,

Chris.
---------------

Re:TStringList Key/Value Pair


Thanks Chris.. I'll check the Help File!

"Chris R. Timmons" <ctimm...@NOSPAMlgrs.com> wrote in message
news:Xns90AE5BC23C054ctimmonslgrscom@207.105.83.65...

Quote
> Faadiel Rehman" <freh...@santanatech.com> wrote in
> news:3b0fcfb4$1_2@dnews:

> > Sorry for the simple question but how would one implement a
> > name/value pair in a TStringList;

> > I have a function that accepts a TStringList and then it uses the
> > Name property to locate a value;

> > for i:=0 to Params.Count do
> > begin

> >   if Params[i].Name = 'Content1' then
> >   begin
> >     xxx := Params[i].Values;
> >     break;
> >   end;

> > end;

> Faadiel,

> Look in the help file under TStrings.Names, TStrings.Values and
> TStrings.IndexOfName.

> Basically, if the name/value pairs in your stringlist have the format
> name=value, then the following code will retrieve a value for a given
> name:

>   MyValue := Params.Values['Content1'];

> HTH,

> Chris.
> ---------------

Re:TStringList Key/Value Pair


Gee!! Thanks man it was so simple all I had to do was RTFM. "Read The
F$%@#$% Manual".

Sometimes one gets really lazy.

Faadiel

"Chris R. Timmons" <ctimm...@NOSPAMlgrs.com> wrote in message
news:Xns90AE5BC23C054ctimmonslgrscom@207.105.83.65...

Quote
> Faadiel Rehman" <freh...@santanatech.com> wrote in
> news:3b0fcfb4$1_2@dnews:

> > Sorry for the simple question but how would one implement a
> > name/value pair in a TStringList;

> > I have a function that accepts a TStringList and then it uses the
> > Name property to locate a value;

> > for i:=0 to Params.Count do
> > begin

> >   if Params[i].Name = 'Content1' then
> >   begin
> >     xxx := Params[i].Values;
> >     break;
> >   end;

> > end;

> Faadiel,

> Look in the help file under TStrings.Names, TStrings.Values and
> TStrings.IndexOfName.

> Basically, if the name/value pairs in your stringlist have the format
> name=value, then the following code will retrieve a value for a given
> name:

>   MyValue := Params.Values['Content1'];

> HTH,

> Chris.
> ---------------

Re:TStringList Key/Value Pair


On Sat, 26 May 2001 11:44:12 -0700, "Faadiel Rehman"

Quote
<freh...@santanatech.com> wrote:
>Sorry for the simple question but how would one implement a name/value pair
>in a TStringList;

May be it's this what you mean:

MyStringList.Items.Add ('SomeName=SomeValue');

Manuel Algora
m...@encomix.es

Other Threads