ColdFusion 9.0 Resources |
Dynamic variable limitationWhen you use a dynamic variable name in quotation marks on the left side of an assignment, the name must be either a simple variable name or a complex name that uses object.property notation (such as MyStruct.#KeyName#). You cannot use an array as part of a dynamic variable name. For example, the following code generates an error: <cfset MyArray=ArrayNew(1)> <cfset productClassNo = 1> <cfset productItemNo = 9> <cfset "myArray[#productClassNo##productItemNo#]" = "Widget"> However, you can construct an array index value dynamically from variables without using quotation marks on the left side of an assignment. For example, the preceding sample code works if you replace the final line with the following line: <cfset myArray[#productClassNo# & #productItemNo#] = "Widget"> |