All variables are part of a variable scope. When you write 
<cfset name="Mark"> 
you are actually writing shorthand for 
<cfset variables.name = "Mark">
or 
<cfset variables["name"] = "Mark">

That's all very well, but the shorthand breaks down if you want to use
dynamic variable names (and the dotted notation breaks down too). What
you are seeing here is a situation where you need to revert to full
variable names. Sure you can use the two workarounds Jacob has
described, or you can write...

You can create a dynamic variable name like so:
<cfset variables["db_name#i#"] = db_name>
And then access it using
#variables["db_name#i#"]#

You can see this notation above is the same as you would do for session
variables. 

-----Original Message-----
From: Mark Henderson [mailto:[EMAIL PROTECTED] 
Sent: Friday, 23 December 2005 1:01 p.m.
To: CF-Talk
Subject: RE: Appending a variable to another variable

<snip>
You can create a dynamic variable name like so:
<cfset "db_name#i#" = db_name>
And then access it using evaluate():
#evaluate("db_name#i#")#
</snip>

Thanks Jacob, that works. I do still wonder why it's not necessary with
session variables.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:227575
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to