title: Delphi Tstringlist, get strings as a quoted, comma delimited string?
body: <p>I have a Tstringlist containing a list of keys used in a database table.
  I'd like a simple way to generate one string containing all the keys, with each separated by a comma and enclosed in single quotes.
  This is so that it can be used in a SQL 'IN' statement 
  eg <em>WHERE FieldX IN ('One','Two','Three')</em>.</p>
  
  <p>I've tried using quotechar but it is ignored when <em>reading</em> the commatext.
  eg the following code </p>
  
  <pre><code>procedure junk;
  var
    SL : Tstringlist;
    s : string;
  begin
   SL := Tstringlist.Create;
   SL.Delimiter :=','; //comma delimiter
   SL.QuoteChar := ''''; //single quote around strings
   SL.Add('One');
   SL.Add('Two');
   SL.Add('Three');
   try
     s :=  SL.commatext;
     showmessage(s);
   finally
     SL.Free;
   end; //finally
  end; //junk
  </code></pre>
  
  <p>shows the message  One,Two,Three  - without any quotes.</p>
  
  <p>I know I can do it the long way round, as in</p>
  
  <pre><code>procedure junk;
  var
    SL : Tstringlist;
    s : string;
    i : integer;
  begin
   SL := Tstringlist.Create;
   SL.Delimiter :=','; //comma delimiter
   SL.Add('One');
   SL.Add('Two');
   SL.Add('Three');
   try
   s := '';
   for I := 0 to SL.Count - 1 do
      begin
      s := s +  ',' + '''' + SL[i] + '''';
      end;
   delete(s,1,1);
   showmessage(s);
   finally
     SL.Free;
   end;//finally
  end;
  </code></pre>
  
  <p>but is there a simpler way using properties of the Tstringlist itself?</p>