[thelist] RE: What is the ColdFusion equivalent to eval()?

scott.brady at homeqonline.com scott.brady at homeqonline.com
Tue Apr 24 10:36:28 CDT 2001


jon steele wrote:

> <cfset mayvar1="Hi">
> <cfset mayvar1="Hey">
> <cfset mayvar1="Hello">

> <cfloop index=i from=1 to=3>
> <cfset mess#i# = Evaluate("myvar#i#")>
> </cfloop>

> <cfoutput>#mess1#, #mess2#, #mess3#</cfoutput>

> I want the above to write "Hi, Hey, Hello". As you
> can see I need to use the counter in the name of the
> new variables being created by the loop.

Why not do something like this:

<cfset myvar1="Hi">
<cfset myvar2="Hey">
<cfset myvar3="Hello">

<cfoutput>
<cfloop index=i from=1 to=3>
#Evaluate("myvar" & i)#,
</cfloop>
</cfoutput>

(you'd need some conidtional code to not print out the third comma, but that's
easy)

Scott







More information about the thelist mailing list