Sign in to follow this  
Followers 0
dainiusb

Combine variable name

6 posts in this topic

Local $abc1 = 2
Local $abc2 = 3
Local $abc3 = 4

MsgBox(0, "", $abc & 2)

Something like that. $abc + 2 = $abc2 Can this be done in AutoIt?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Yes: Look at Eval() in the help file.

Edited by czardas

Share this post


Link to post
Share on other sites

I don't understand how to do it. I see Eval and Assign as completely different things than I need.

From examples I understand that Assign is used to assign data to a variable and eval finds out the value but how is this useful? I don't get how it works.

Share this post


Link to post
Share on other sites

Eval takes an expression. This means a string is acceptable rather then an actual variable.

Example

Local $abc1 = 2
Local $abc2 = 3
Local $abc3 = 4

For $1 = 1 To 3
    MsgBox(0, $1, Eval('abc' & $1))
Next

All 3 variables are shown in the loop by using the expression of 'abc' & $1

Share this post


Link to post
Share on other sites

Eval takes an expression. This means a string is acceptable rather then an actual variable.

Example

Local $abc1 = 2
Local $abc2 = 3
Local $abc3 = 4

For $1 = 1 To 3
    MsgBox(0, $1, Eval('abc' & $1))
Next

All 3 variables are shown in the loop by using the expression of 'abc' & $1

Ooh! Now I see it. Thank You.

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