Jump to content

variable variables


alexx
 Share

Recommended Posts

Can you make a new variable each time something happens ... e.g. first $1, then $2, then $3... etc ?

I am not that great at autoit but I might be able to help since there are not very man people on. Could you rephrase the question? Do you want to add to the variable and make it bigger?

Link to comment
Share on other sites

You may want to use Assign() to create your variables and then use Eval() to use them.

Small example

; Create variables
For $i = 1 To 3
    Assign('var' & $i, $i * 20)
Next

; Display variables
For $i = 1 To 3
    MsgBox(0, IsDeclared('var' & $i), Eval('var' & $i))
Next

:whistle:

Edit:

But using an array could be easier if suitable.

Edited by MHz
Link to comment
Share on other sites

YAY I can use arrays now! took me a while to get it right but it was exactly what I wanted! (I tried assign and eval but I still dont understand them)

but I have a question... when starting the array I used Dim $Array[1] like in the example but why do you have to include the [1] to use the array? It's annoying having a first blank :whistle:

Link to comment
Share on other sites

An array is like a box of a dozen eggs. The box is the array in total of 12 elements ($box[11]). To get your fingers on the first egg, then you need to following a rule governed by using a number as an index. So you would use $box[0] to access the first egg, $box[1] for the second and so on. Arrays in AutoIt start from an index of 0.

Look here for more help with arrays.

http://www.autoitscript.com/wiki/index.php?title=Arrays

:whistle:

Link to comment
Share on other sites

YAY I can use arrays now! took me a while to get it right but it was exactly what I wanted! (I tried assign and eval but I still dont understand them)

but I have a question... when starting the array I used Dim $Array[1] like in the example but why do you have to include the [1] to use the array? It's annoying having a first blank :whistle:

Have a look at the _Array* functions (help file).

#include <Array.au3>

$avArray = _ArrayCreate("Jim Bob")
_ArrayDisplay( $avArray, "Array" )
_ArrayAdd( $avArray,"Marry Ellen")
_ArrayDisplay( $avArray, "Updated Array" )

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...