Home > Mobile >  convert a long string into a Tstringlist
convert a long string into a Tstringlist

Time:03-11

hello guys I have the following string A type string.

A = 'flagA=0,flagB=0,flagC=1'

B:Tstringlist.

I want to convert it into Tstringlist in order to see if the flagC is set to 1 by inspecting B.Values['flagC'].

perhaps i need to split the string under '=' and ',' ? Any other ideas are welcome thanks.

CodePudding user response:

This should work

B := TStringList.Create;

B.Delimiter := ',';
B.DelimitedText := 'flagA=0,flagB=0,flagC=1';

ShowMessage(B.Values['flagC']);

cars.Free;
  • Related