Daniel Jean had a problem with the ListAppend function. "If I run the following code:
<CFSET temp = ""> <CFLOOP index="i" from=1 to=10> <CFSET temp = ListAppend(temp, i, "AND")> </CFLOOP> |
" I get:
1A2A3A4A5A6A7A8A9A10
"instead of the intended
1AND2AND3AND4AND5AND6AND7AND8AND9AND10
"It looks as though the ListAppend will only allow the delimiter to be one character, although the documentation for other List functions specifies that it can be a string and the examples use a multi-character delimiter (see the example for ListChangeDelim). There are certainly manual workarounds, but ColdFusion functions run a whole lot faster than manual workarounds."
Howard notes that "This is happening because the delimiters field in the List functions is not a string to be used as a single delimiter, but rather a set of characters that can _all_ be delimiters. CF is using the first delimiter available, 'A' in your example."
Mary Catherine Gerrey suggested a workaround: "Use something else as the delimiter (like &) and then go back and do a replace on all '&'s with 'AND'."
In response to this discussion, Michael Dinowitz reminds us that "string," in this usage and many others, really can mean just a single character (a letter, number or symbol), and this is the meaning here, as well. He also recommends the search and replace workaround.