Sign in to follow this  
Followers 0
Zephir

Array question

3 posts in this topic

hello,

I am in big need for an undefined array. The user shall have the option to set his array size. I allready tried this:

Dim $realArray = _myArrayCreate(200)

func _myArrayCreate($size)
    local $tmpArray[$size]
    for $i = 1 to $size
        $tmpArray[$i] = 0
    Next
    return $tmpArray
Endfunc

This just does not work for me. The problem seems to be the first line of the function (local $tmpArray[$size]). AutoIt cannot parse this line.... :)

any suggestions?

Share this post


Link to post
Share on other sites



Arrays are zero-indexed. When you define an element with 200 elements, the first element is zero and the last is 199.

Start your loop at 0 instead of 1 and end it at $size-1.

Share this post


Link to post
Share on other sites

oh man. i feel sooo stupid :)

should have thought of that myself ..

big thanks to you weaponx

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