Jump to content
Sign in to follow this  
magaf

variable as a variable's name?

Recommended Posts

magaf

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
this-is-me

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
trids

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

Share this post


Link to post
Share on other sites
magaf

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
jhocott

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
magaf

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
this-is-me

Yes.


Who else would I be?

Share this post


Link to post
Share on other sites
magaf

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

Share this post


Link to post
Share on other sites
magaf

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
SlimShady

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.