Jump to content
Sign in to follow this  

[Closed] _ArrayDelete() and _ArrayAdd()

Recommended Posts



If I have a simple 1D Array that has some elements,

and the user can Add and Delete to/from that array,

everything works fine,

except when the user Deletes all items.

It seems like after _ArrayDelete() deletes all items,

the Array loses its "Arrayness",

and then when I try to do _ArrayAdd() again, the _ArrayAdd() function sees the obejct as a non-array.

What can I do to fix this, so even if the user deletes all items, he can still add new ones later?

Edited by Zohar

Share this post

Link to post
Share on other sites

to delete all array elements.. just redeclare the array.. that will erase all elements.. n u can define the dimensions too..

If u don't want to do this, then please post ur code, for us to identify the problem..

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post

Link to post
Share on other sites

When _ArrayDelete reomves the last element, it destroys the Array. So you should use a wrapper func, that re-creates the Array if necessary:

Func _ArrayAddCreate(ByRef $avArray, $vValue)
    ; Prog@ndy
    If Not IsArray($avArray) Then
        Dim $avArray[1] = [$vValue]
        Local $ret = _ArrayAdd($avArray,$vValue)
        Return SetError(@error,@extended,$ret)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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.