i have a loop setup on an insert that was running fine on cf9, but on cf10 it is erroring with an "expressions error" code is: <cfloop index="x" from="1" to="#cc#" step="1"> <cfif IsDefined("FORM.["Interest" & #x#]") AND FORM.["Interest" & #x#] is 1> |
Sorry, but that code you specify there will not run on any version of ColdFusion.
Firstly you have a syntax error in your variable referencing as others have pointed out. This is invalid:
FORM.["Interest" & #x#]
It needs to be this:
FORM["Interest" & #x#]
(ie: without the dot).
Secondly, isDefined() only works with dot-notation variable names, eg: form.interest1 etc. It cannot be used with associative array syntax or any other sort of notation. so - syntax errors aside - this will not work:
IsDefined("FORM.["Interest" & #x#]")
(oh... a third error... if you're using double quotes as the string delimiter, and have embedded double quotes in the string, you need to escape them, eg "". However that is neither here nor there in this situation, as the code is broken in two other ways anyhow.
So you're giving us misleading information there.
What you want to be using is this:
structKeyExists(form, "Interest#x#") and form["Interest#x#"]
Although using the & operator will work fine there too, instead of the inline variable resolution.
Avoid isDefined() altogether if poss, as it's a bit old and creaky and gives false positives compared to using structKeyExists(), which just works.
--
Adam