Zohar Posted February 14, 2009 Share Posted February 14, 2009 (edited) 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 March 2, 2009 by Zohar Link to comment Share on other sites More sharing options...
Manjish Posted February 14, 2009 Share Posted February 14, 2009 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 More sharing options...
ProgAndy Posted February 14, 2009 Share Posted February 14, 2009 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 More sharing options...
Zohar Posted February 14, 2009 Author Share Posted February 14, 2009 Prog-ND: thank you :] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now