Yes, I have done this often, using evaluate. Don't tell anyone tho, as Evaluate is hated on for some reason, personally I love it.

An equivalent for your PHP code would be:

<CFSCRIPT>
i = 123;
j = "i";
writeoutput(Evaluate(j));
// output is "123"
</CFSCRIPT>

NB: As structures are by-reference variables (pointers!), you do not need to do this. Simply do:

circuitlang = Application.language.circuitname;
// circuitlang.stringname is now the equivalent of  Application.language.circuitname.stringname

assuming language and circuitname are structures...

HTH
Aaron

----- Original Message -----
From: Damien McKenna
To: CF-Talk
Sent: Saturday, July 10, 2004 12:24 AM
Subject: Variable variables?

Does CFML support variable variables?

In PHP you can define a variable and then define another variable to
point to it, e.g.:

$i = 123;
$j = $$i;
print $j;
// output is "123"

Is there something similar in CFML?  At a cursory glance of the books I
have looks like it isn't possible.

In my situation I've got variables with pretty long names, e.g.
#Application.language.circuitname.stringname# and would like to be able
to reference it by a shorter method, e.g. circuitlang.stringname, while
still retaining the Application scope.

Thanks.
--
Damien McKenna - Web Developer - [EMAIL PROTECTED]
The Limu Company - http://www.thelimucompany.com/ - 407-804-1014
"Nothing endures but change." - Heraclitus
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to