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

jon steele jjsteele22 at yahoo.com
Tue Apr 24 10:12:33 CDT 2001


Thanks Lindsay,

But I'm still having some trouble. I am trying to use
my counter (i) in the name of the variables I am
declaring, creating a list variables like myvar1,
myvar2, etc. But I can't do this becuase CF tells me I
can't use Evaluate on the left hand-side. Is there
another way? This is what I was testing with:

<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 wasnt 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.

Jon.


Lindsay's Message:
> In JavaScript and php we can use eval() to
> do this, but how can I do it in ColdFusion?

Evaluate()

> Also, is the #i# used in the ListToArray function
> correct?

umm, I don't think so, ListToArray() has to have a
list as the first
argument, what your are passing there will be the
string "my_arr[x]" 
(where
x is whatever value i is in the loop)

If you are trying to do what I think you're doing,
then you need
ListToArray(my_arr[i], "-")

hth

--
 Lindsay Evans. 

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/




More information about the thelist mailing list