Tally List : mailing list management, archiving, and analysis
click for archive home
 
Archive of:
CF-Talk
Cold Fusion - Technical
 
home
24 hour view
quick stats
weekly updates
 
all tallylists
corporate solutions
archive your favorite
help / feedback


Search the Tallylist search by keyword:

About Cold Fusion :
product's home
product's list home
 
  Archived TallyList / CF-Talk: 
Subject: RE: dynamically naming variables
Jeremy Allen (47p/+1r)     Posted: Wednesday 20 Dec 2000
This post: 227 views, +1 rating

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>

<cfoutput><br>#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:jay@zeddcomm.com] >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 >jay@zeddcomm.com > >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 > < > < > < > > > > >


Similar Subject Line Posts (+/- two weeks of this post)
Re: dynamically naming variables  21 Dec 2000   (84 v/ +0 r)
Re: dynamically naming variables  21 Dec 2000   (91 v/ +0 r)
Re: dynamically naming variables  21 Dec 2000   (73 v/ +0 r)
RE: dynamically naming variables  20 Dec 2000   (86 v/ +0 r)
Re: dynamically naming variables  20 Dec 2000   (98 v/ +0 r)
RE: dynamically naming variables  20 Dec 2000   (88 v/ +0 r)
RE: dynamically naming variables  20 Dec 2000 (this post)   (227 v/ +1 r)
dynamically naming variables  20 Dec 2000   (96 v/ +0 r)
 

Send a reply to the CF-Talk list!
click to send a reply! NOTE: Many lists will reject your post unless you have already registered with them. Also - don't forget the right account to send from (for those with multiple emails!)

Feedback: If this post was exceptionally helpful, please help by giving this post a positive review.

 

TallyList : copyright Ububik - 2000