delphipascallazarus

convert a long string into a Tstringlist


I have the following string A type string.

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

I also have

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.


Solution

  • This should work

    B := TStringList.Create;
    
    B.Delimiter := ',';
    B.DelimitedText := 'flagA=0,flagB=0,flagC=1';
    
    ShowMessage(B.Values['flagC']);
    
    cars.Free;