Jump to content

[Closed] _ArrayDelete() and _ArrayAdd()


Zohar
 Share

Recommended Posts

Hello

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
Link to comment
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
Link to comment
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]
    Else
        Local $ret = _ArrayAdd($avArray,$vValue)
        Return SetError(@error,@extended,$ret)
    EndIf
EndFunc

*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

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...