Reputation: 32905
Ok, this func doesn't make sense, but I'm just using it as an example:
<cffunction name="blah">
<cfset var myFoo = 123>
<cfset var varNamePrefix = "my">
<cfset var bar = Evaluate("#varNamePrefix#Foo")>
<cfreturn bar>
</cffunction>
With CF9, I can use local["#varNamePrefix#Foo"]
. Is there a way for CF7/8 to get rid of the Evaluate()
without refactoring the whole thing with var local = structNew()
?
Upvotes: 1
Views: 91
Reputation: 28873
Not by documented means. Pre-CF9 there is only getPageContext().getActiveFunctionLocalScope()
<cffunction name="blah">
<cfset var myFoo = 123>
<cfset var varNamePrefix = "my">
<!--- ie object.method()[keyName] syntax does not seem to be supported --->
<cfset var localScope = getPageContext().getActiveFunctionLocalScope()>
<cfset var bar = localScope["#varNamePrefix#Foo"]>
<cfreturn bar>
</cffunction>
Upvotes: 6