Using ListAppend and dynamic variables
Hello all,
I have an example that is causing me trouble.
If I do the following, things work as expected.
CODE:
<cfoutput query="Customers">
<cfset var2 = listAppend(var2, #Customers.accno#)>
</cfoutput>
OUTPUT: #var2#
RESULTS: 553,610
The problem is that my output changes unexpectedly if I change my code.
CODE:
<cfoutput query="Customers">
<cfset var#Customers.key# = listAppend(var#Customers.key#, #Customers.accno#)>
</cfoutput>
OUTPUT: var#Customers.key#
RESULTS: var2,610
For a reason I haven't been able to determine, the ListAppend (or simple concatenate for that matter) is pre-pending the name of the dynamic variable to the list. I can only assume it is the manner in which ColdFusion evaluates the statement but I'm not sure how to work around it.
Thanks for any help!
