Adobe ColdFusion 8

SetVariable function considerations

You can avoid using the SetVariable function by using a format such as the following to set a dynamically named variable. For example, the following lines are equivalent:

<cfset SetVariable("myVar" & i, myVal)>
<cfset "myVar#i#" = myVal>

In the second line, enclosing the myVar#i# variable name in quotation marks tells ColdFusion to evaluate the name and process any text in number signs as a variable or function. ColdFusion replaces the #i# with the value of the variable i, so that if the value of i is 12, this code is equivalent to the line

<cfset myVar12 = myVal>

For more information on this usage, see Using number signs to construct a variable name in assignments.