Any way to get TStringList.CommaText to not escape commas with quotes?

Posted by Mason Wheeler on Stack Overflow See other posts from Stack Overflow or by Mason Wheeler
Published on 2010-06-10T17:57:15Z Indexed on 2010/06/10 18:13 UTC
Read the original article Hit count: 315

I'm doing some work with code generation, and one of the things I need to do is create a function call where one of the parameters is a function call, like so:

result := Func1(x, y, Func2(a, b, c));

TStringList.CommaText is very useful for generating the parameter lists, but when I traverse the tree to build the outer function call, what I end up with looks like this:

result := Func1(x, y, "Func2(a, b, c)");

It's quoting the third argument because it contains commas, and that produced invalid code. But I can't do something simplistic like StringReplace all double quotes with empty strings, because it's quite possible that a function argument could be a string with double quotes inside. Is there any way to make it just not escape the lines that contain commas?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about code-generation