Happy Friday All,
Been trying to crack this for a couple days. What I am looking to do is dynamically create a variable using a combination of a fixed string and a
One Option:
Setting a dynamic variable name:
<cfset variables["GC" & AID] = "Testing" />
Output the value of the dynamic variable name:
<cfoutput>#variables["GC" & AID]#</cfoutput>
Another Option:
Setting a dynamic variable name:
<cfset variables["GC#AID#"] = "Testing" />
Output the value of the dynamic variable name:
<cfoutput>#variables["GC#AID#"]#</cfoutput>
All variable scope are structs. So loop through that scope as a struct. As your code is written, it's in the variables scope. I'd put it in it's own struct, but here's a hacked up version of what you're trying to do:
<cfloop collection="#variables#" item="k">
<cfif left(k,2) eq "GC">
<cfoutput>#k# : #variables[k]#</cfoutput><br/>
</cfif>
</cfloop>