Jump to content
Sign in to follow this  

Array with assign

Recommended Posts



How use array with assign function ?

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


Share this post

Link to post
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.


My Contributions: Unix Timestamp: 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 this post

Link to post
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]
    $avTemp[0] = UBound($avTemp) - 1
    Assign("av" & $n, $avTemp)

; 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

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.