Sign in to follow this  
Followers 0
magaf

variable as a variable's name?

12 posts in this topic

#1 ·  Posted (edited)

is that possible ?

example

$x = abc

$($x) = def

so the var $abc contains def

Edited by magaf

Share this post


Link to post
Share on other sites



If you mean does

$var = "$var"

or

$var = "var"

work, then the answer is yes.


Who else would I be?

Share this post


Link to post
Share on other sites

See if the function Eval() in the helpfile answers your question

Share this post


Link to post
Share on other sites

thanks for responding through im yet to find a solution for what i ment, the variable content is unknown (the reason i want to make variable (ehich will refer to its content) as a variable's name) so i cant use assign

Share this post


Link to post
Share on other sites

Many thanks for this dialogue. Eval satisfies my need for indirection. Coincidentally, I was searching for the same thing.


Jay

Share this post


Link to post
Share on other sites

thanks , that solved it. btw can i do this with arrays also? (array's name would be a variavle's content (thats basicly what i wanted to achieve))

Share this post


Link to post
Share on other sites

Yes.


Who else would I be?

Share this post


Link to post
Share on other sites

how and how could i work with an enviorment variable after?

Share this post


Link to post
Share on other sites

can i make envierment variable arrays and if not what other is there other way to do variable as a variable's name or cant it be done yet with autoit?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

variable as a variable's name

<{POST_SNAPBACK}>

$x = "abc"
Assign($x, $x)
MsgBox(0, "", Eval($x))

As Cyberslug, you need the latest unstable version to make it work.

Available below.

http://www.autoitscript.com/autoit3/files/unstable/autoit/

Edit 1:

Made a good example.

Edit 2:

I just checked your first post...

Here's the working version of your example.

$x = "abc"
Assign($x, "def")

var $abc contains "def" (without quotes)

Edited by SlimShady

Share this post


Link to post
Share on other sites

thanks :ph34r:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0