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?
StringList.CommaText. Or move to the next unlikely until you get one not used in yourStringList.CommaText. (Assert that you find one)QuoteCharfor your StringListStringList.DelimitedText. You’ll get theQuoteChararound the function parameters like:result := Func1(x, y, †Func2(a, b, c)†);QuoteChar(here †) by empty strings…