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#")# 

> -----Original Message-----
> From: Mark Henderson [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 22, 2005 3:43 PM
> To: CF-Talk
> Subject: Appending a variable to another variable
> 
> I have this working using session variables, and it's no big deal, but
> there must be another way to do this.
>  
> Basically, what I want to be able to do is append a counter 
> variable to
> an existing variable name. For instance, let's assume the following
> truncated working code:
>  
> <cfset mail_recipients = "[EMAIL PROTECTED]">
> <cfset session.db_name1 = "d:\serverpath\databases\admin.mdb">
> <cfset session.db_name2 = "d:\serverpath\databases\answer.mdb">
> <cfset session.title1 = "Admin Database">
> <cfset session.title2 = "Answer Database">
>  
> <!-- loop over the variables, gzip the db and send the email --->
> <cfloop from="1" to ="2" index="i">
>  
> <cfx_gzip 
>  action = "gzip"
>  infile  = "#session['db_name'&i]#"
>  level  = "9">
>  
> <cffile 
>  action  = "move"
>  source  = "#session['db_name'&i]#.gz"
>  destination = "#session['db_name'&i]#.gz">
>  
> <cfmail  
>  to   = #mail_recipients#
>  from   = "[EMAIL PROTECTED]"
>  subject  = "LDC #session['title'&i]# for
> #DateFormat(Now(),"yyyy-Mm-dd")#">
>  <CFMAILPARAM FILE="#session['db_name'&i]#.gz">
> </cfmail>
>  
> </cfloop>
>  
> Appending the relevant i counter to the db_name and title 
> works fine as
> long as I use session variables with that syntax eg
> ="#session['db_name'&i]#. But there must be a way to do this without
> having to use sessions. Any ideas? I tried changing session to
> attributes and also variables, but both throw a wobbly and say they
> can't find #attributes['db_name'&i]# ... 
>  
> I forgot to mention, I'm on a CF5 server here.
>  
> TIA
> Mark


[INFO] -- Access Manager:
This transmission may contain information that is privileged, confidential 
and/or exempt from disclosure under applicable law.  If you are not the 
intended recipient, you are hereby notified that any disclosure, copying, 
distribution, or use of the information contained herein (including any 
reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in 
error, please immediately contact the sender and destroy the material in its 
entirety, whether in electronic or hard copy format.  Thank you.   A2



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:227567
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to