# Array with assign

## Recommended Posts

Hi,

How use array with assign function ?

Or do the same thing but with another function cause array("variable" & [0],"text") don't work

P

##### Share on other sites

Hello bloodwolf,

First, Welcome to the AutoIt Forums

From the Help file under Assign(): 'The name of the variable you wish to assign. Cannot be an array element'

This function cannot be used with arrays.

If you were to explain what it is that you need, what you expect as a result. Someone, might be able to help you with a solution.

Realm

My Contributions: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.

##### Share on other sites

You cannot use the array variable syntax to work with ELEMENTS of an array, but you can Assign()/Eval() the whole array variable to a known \$TEMP in order to work with it. As in this demo:

```#include <Array.au3>

Global \$av1[4] = ["North", "South", "East", "West"]
Global \$av2[5] = ["Zero", "One", "Two", "Three", "Four"]
Global \$avTemp[1]

; Put a count in [0] of each array
For \$n = 1 To 2
\$avTemp = Eval("av" & \$n)
ReDim \$avTemp[UBound(\$avTemp) + 1]
For \$i = UBound(\$avTemp) - 2 To 0 Step -1
\$avTemp[\$i + 1] = \$avTemp[\$i]
Next
\$avTemp[0] = UBound(\$avTemp) - 1
Assign("av" & \$n, \$avTemp)
Next

; Display
_ArrayDisplay(\$av1, "\$av1")
_ArrayDisplay(\$av2, "\$av2")```

P.S. This doesn't change the inherent evil that is the heart of Assign()/Eval()!

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Ok ty

## Create an account

Register a new account