Re: dynamically naming variables
On 12/20/00, Jay Brushett penned: Hi, I need to use the Evaluate function to dynamically name variables in a cfloop. Using the function on the right hand side of a cfset works fine of course but CF won't let me use it on the left hand side (i.e. the variable name). Any ideas would be greatly appreciated. This will show you using randrange as the value were setting each one at. I'd preume you're looping through a list or whatnot to get the values. This will name the variables var1, var2, var3, etc. cfloop index="num" from="1" to="10" cfset random = randrange(100, 200) cfset varname = "var" num cfset "#varname#" = random CFOUTPUTvariable #num# = #evaluate(varname)#br/CFOUTPUT /cfloop -- Bud Schneehagen - Tropical Web Creations _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ColdFusion Solutions / eCommerce Development [EMAIL PROTECTED] http://www.twcreations.com/ 954.721.3452 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: dynamically naming variables
Thanks everyone! Really appreciate all the help. Jay At 08:40 AM 12/21/2000 -0500, you wrote: On 12/20/00, Jay Brushett penned: Hi, I need to use the Evaluate function to dynamically name variables in a cfloop. Using the function on the right hand side of a cfset works fine of course but CF won't let me use it on the left hand side (i.e. the variable name). Any ideas would be greatly appreciated. Strategy ~ Creativity ~ Technology Jay Brushett [EMAIL PROTECTED] Developer ZeddComm Inc. 2nd Floor, The Tower | 100 Signal Hill Road St. John's, Newfoundland | Canada A1A 1B3 Main: 709.570.5669 | Fax: 709.739.9003 Web: www.zeddcomm.com St. John's ~ New York ~ Newport Beach ~ Ottawa ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
dynamically naming variables
Hi, I need to use the Evaluate function to dynamically name variables in a cfloop. Using the function on the right hand side of a cfset works fine of course but CF won't let me use it on the left hand side (i.e. the variable name). Any ideas would be greatly appreciated. TIA, Jay Strategy ~ Creativity ~ Technology Jay Brushett [EMAIL PROTECTED] Developer ZeddComm Inc. 2nd Floor, The Tower | 100 Signal Hill Road St. John's, Newfoundland | Canada A1A 1B3 Main: 709.570.5669 | Fax: 709.739.9003 Web: www.zeddcomm.com St. John's ~ New York ~ Newport Beach ~ Ottawa ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: dynamically naming variables
cfset "product#id#" = aNumber Robert -Original Message- From: Jay Brushett [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 20, 2000 9:54 AM To: CF-Talk Subject: dynamically naming variables Hi, I need to use the Evaluate function to dynamically name variables in a cfloop. Using the function on the right hand side of a cfset works fine of course but CF won't let me use it on the left hand side (i.e. the variable name). Any ideas would be greatly appreciated. TIA, Jay Strategy ~ Creativity ~ Technology Jay Brushett [EMAIL PROTECTED] Developer ZeddComm Inc. 2nd Floor, The Tower | 100 Signal Hill Road St. John's, Newfoundland | Canada A1A 1B3 Main: 709.570.5669 | Fax: 709.739.9003 Web: www.zeddcomm.com St. John's ~ New York ~ Newport Beach ~ Ottawa ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: dynamically naming variables
Here is a quick example of dynamic variable usage. cfset listVarNames = "foo,bar,dynamic,variables,rule" cfloop list="#listVarNames#" index="i" cfset "#i#DynamicVars" = "#i#DynamicVars" cfoutput#Evaluate(i "DynamicVars")#/cfoutput /cfloop cfoutputbr#fooDynamicVars#br#barDynamicvars#br#dynamicDynamicVars#b r#variablesDynamicVars#br#ruleDynamicVars#/cfoutput OUTPUTS: fooDynamicVars barDynamicVars dynamicDynamicVars variablesDynamicVars ruleDynamicVars fooDynamicVars barDynamicVars dynamicDynamicVars variablesDynamicVars ruleDynamicVars Thats all it takes. (sneaky ehh?:) There are a few "rules" if you will about your dynamic variables and the names they can have numbers, letters and underscores. You must start a variable with a letter. CF Interprets upper and lower case to be the same , no case sensitivity. Well, that's a quick and dirty version of the rules for using dynamic variables (and cf variables in general) You cant really "assign" a value to a coldfusion function, CF does nto grock that. If what your trying to do did not fit into the rules I just mentioned you probably can't do it :) :-) BTW, if you find the cfset line confusing replace it with cfset "#i#DynamicVars" = "Just a plain ole string going into my dynamic variable" Jeremy Allen elliptIQ Inc. -Original Message- From: Jay Brushett [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 20, 2000 10:54 AM To: CF-Talk Subject: dynamically naming variables Hi, I need to use the Evaluate function to dynamically name variables in a cfloop. Using the function on the right hand side of a cfset works fine of course but CF won't let me use it on the left hand side (i.e. the variable name). Any ideas would be greatly appreciated. TIA, Jay Strategy ~ Creativity ~ Technology Jay Brushett [EMAIL PROTECTED] Developer ZeddComm Inc. 2nd Floor, The Tower | 100 Signal Hill Road St. John's, Newfoundland | Canada A1A 1B3 Main: 709.570.5669 | Fax: 709.739.9003 Web: www.zeddcomm.com St. John's ~ New York ~ Newport Beach ~ Ottawa ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: dynamically naming variables
This is how i use dynamic variable names on the left side of a cfset there's probably other ways to do it too CFLOOP from="1" to="20" index="i" CFSET varname = "myvar" i CFSET "#varname#" = i /CFLOOP Allan Pichler Machine Dreams Inc. -Original Message- From: Jay Brushett [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 20, 2000 7:54 AM To: CF-Talk Subject: dynamically naming variables Hi, I need to use the Evaluate function to dynamically name variables in a cfloop. Using the function on the right hand side of a cfset works fine of course but CF won't let me use it on the left hand side (i.e. the variable name). Any ideas would be greatly appreciated. TIA, Jay Strategy ~ Creativity ~ Technology Jay Brushett [EMAIL PROTECTED] Developer ZeddComm Inc. 2nd Floor, The Tower | 100 Signal Hill Road St. John's, Newfoundland | Canada A1A 1B3 Main: 709.570.5669 | Fax: 709.739.9003 Web: www.zeddcomm.com St. John's ~ New York ~ Newport Beach ~ Ottawa ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists