mjolnirmarkiv Posted December 14, 2014 Share Posted December 14, 2014 $avResult "array variable has incorrect number of subscripts..." error appears in _ArrayFindAll when function used in example below: #include <Array.au3> Global $array[1][3] = [["a", "b", "a"]] _ArrayDisplay (_ArrayFindAll ($array, "a", 0, 0, 0, 0, 0, true)) Should be like this I believe. Change in line "$avResult[uBound($avArray, $bRow + 1)]", originally was "$avResult[uBound($avArray)]": Func _ArrayFindAll(Const ByRef $avArray, $vValue, $iStart = 0, $iEnd = 0, $iCase = 0, $iCompare = 0, $iSubItem = 0, $bRow = False) If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iCase = Default Then $iCase = 0 If $iCompare = Default Then $iCompare = 0 If $iSubItem = Default Then $iSubItem = 0 If $bRow = Default Then $bRow = False $iStart = _ArraySearch($avArray, $vValue, $iStart, $iEnd, $iCase, $iCompare, 1, $iSubItem, $bRow) If @error Then Return SetError(@error, 0, -1) Local $iIndex = 0, $avResult[UBound($avArray, $bRow + 1)] Do $avResult[$iIndex] = $iStart $iIndex += 1 $iStart = _ArraySearch($avArray, $vValue, $iStart + 1, $iEnd, $iCase, $iCompare, 1, $iSubItem, $bRow) Until @error ReDim $avResult[$iIndex] Return $avResult EndFunc ;==>_ArrayFindAll If so, worth creating new ticket as I haven't find similar one posted earlier and bug persists in beta, unfrotunately my IP has been banned by Trac. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 14, 2014 Moderators Share Posted December 14, 2014 1st, ArrayDisplay requires a variable to be passed. Notice that the first parameter is "ByRef". 2nd, that function looks crazy... nothing like I'd expect the results to be provided. Not sure if I like that it only deals with this in a 1D type of manner even though it attempts to work with 2D as well. See if this works: Func _ArrayFindAll_(Const ByRef $avArray, $vValue, $iStart = 0, $iEnd = 0, $iCase = 0, $iCompare = 0, $iSubItem = 0, $bRow = False) If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iCase = Default Then $iCase = 0 If $iCompare = Default Then $iCompare = 0 If $iSubItem = Default Then $iSubItem = 0 If $bRow = Default Then $bRow = False Local $avResult[UBound($avArray)], $iIndex = -1, $iErr $iStart -= 1 For $i = 0 To UBound($avResult) - 1 $iStart = _ArraySearch($avArray, $vValue, $iStart + 1, $iEnd, $iCase, $iCompare, 1, $iSubItem, $bRow) $iErr = @error If $iErr Then ExitLoop $iIndex += 1 $avResult[$iIndex] = $iStart Next If $iIndex = -1 Then Return SetError($iErr, 0, 0) ReDim $avResult[$iIndex + 1] Return $avResult EndFunc . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
mjolnirmarkiv Posted December 14, 2014 Author Share Posted December 14, 2014 (edited) 1st, ArrayDisplay requires a variable to be passed. Notice that the first parameter is "ByRef". 2nd, that function looks crazy... nothing like I'd expect the results to be provided. Not sure if I like that it only deals with this in a 1D type of manner even though it attempts to work with 2D as well. 1) Well, I attempt to display array of indices that have been found, not array itself. 2) Nope, it shows [0], but should be [0, 2], i.e. first and last index in 2D array with one row and three columns. But slightly modified function I posted above works Edited December 14, 2014 by mjolnirmarkiv Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2014 Moderators Share Posted December 14, 2014 (edited) mjolnirmarkiv,Nice catch as usual - thanks for the report, and the solution. I will amend the function for the next release. M23And done - in a slightly different way:Local $iIndex = 0, $avResult[UBound($avArray, (($bRow)?($UBOUND_COLUMNS):($UBOUND_ROWS)))] ; Set dimension for Column/Row Edited December 15, 2014 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
souldjer777 Posted May 8, 2015 Share Posted May 8, 2015 (edited) Sorry Melba, I believe we were getting a random commented out ";_ArrayDisplay($avResult, $aUniqueHostname[$i01])" to pop up for some reason after an Local $avResult = _ArrayFindAll($array01, $aUniqueHostname[$i01], 0, 0, 0, 0, 1) No idea why. You can delete this message if you like. Edited May 8, 2015 by souldjer777 "Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"Song Title: I guess you could sayArtist: Middle Class Rut Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 8, 2015 Moderators Share Posted May 8, 2015 souldjer777,Your post above makes no sense to me at all - what relationship is there between the dialog you posted and the earlier bug in _ArrayFindAll?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
antonioj84 Posted May 8, 2015 Share Posted May 8, 2015 since we are in the topic of array , Melba can you tell me why _arraycompare was not added, it's a time saver Link to comment Share on other sites More sharing options...
antonioj84 Posted May 8, 2015 Share Posted May 8, 2015 here are the files for _arraycompare arraycompare.zip Link to comment Share on other sites More sharing options...
iamtheky Posted May 8, 2015 Share Posted May 8, 2015 (edited) Only slightly off topic. And there are many ways to compare arrays, and many different meanings and results that a user could want from a comparison (of which a visual windiff is probably not super extensible). There are some other examples here:Cleaned up my effort:expandcollapse popup#include <Array.au3> Global $aCompare1[10] = [1, 3, 5, 6, 7, 8, 9, 10, 11, 12] Global $aCompare2[10] = [1, 2, 3, 4, 5, 6, 8, 10, 12, 13] $aFinalComp = _ArrayCompare($aCompare1 , $aCompare2) _ArrayDisplay($aFinalComp[0] , 'In Both Arrays') _ArrayDisplay($aFinalComp[1] , 'Only In First Array') _ArrayDisplay($aFinalComp[2] , 'Only In Second Array') Func _ArrayCompare($aArray1 , $aArray2) Local $aBoth[0] Local $aOut[3] For $i = ubound($aArray1) - 1 to 0 step -1 $iMatch = _ArraySearch($aArray2 , $aArray1[$i]) If $iMatch <> -1 then _ArrayAdd($aBoth , $aArray1[$i]) _ArrayDelete($aArray1 , $i) _ArrayDelete($aArray2, $iMatch) EndIf Next For $i = ubound($aArray2) - 1 to 0 step -1 $iMatch = _ArraySearch($aArray1 , $aArray2[$i]) If $iMatch <> -1 then _ArrayAdd($aBoth , $aArray2[$i]) _ArrayDelete($aArray2 , $i) _ArrayDelete($aArray1 , $iMatch) EndIf Next $aOut[0] = $aBoth $aOut[1] = $aArray1 $aOut[2] = $aArray2 return $aOut EndFunc Edited May 8, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 8, 2015 Moderators Share Posted May 8, 2015 souldjer777,I have checked the 3.3.12.0 and 3.3.13.20 Array libraries and there are no additional _ArrayDisplay calls within their _ArrayFindAll functions - I can only imagine you were using a previously posted Alpha version of the function which still had some debugging code within it.antonioj84,Did anyone ask for an _ArrayCompare function when I was looking for input during the Array library rewrite? And as boththose has mentioned, there are so many possible array formats and comparison options that I feel it would be difficult to produce a function which satisfied enough people and was still maintainable by our very small team of volunteers. So I am not at all sure that we would have entertained the idea in any case.And please do not hijack threads - just open a new one next time.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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