ColdFusion 9.0 Resources |
Using number signs to construct a variable name in assignmentsYou can combine text and variable names to construct a variable name on the left side of a cfset assignment. For example, the following code sets the value of the variable Product12 to the string "Widget": <cfset ProdNo = 12> <cfset "Product#ProdNo#" = "Widget"> To construct a variable name this way, all the text on the left side of the equal sign must be in quotation marks. This usage is less efficient than using arrays. The following example has the same purpose as the previous one, but requires less processing: <cfset MyArray=ArrayNew(1)> <cfset prodNo = 12> <cfset myArray[prodNo] = "Widget"> |