poolcat Posted October 6, 2014 Share Posted October 6, 2014 Hi, i found and corrected a little bug in _ArrayExtract. The function is not working correctly with 0-based 2 dim arrays. This is due to the fact that the parameter default is '0' but should be 'Default' - as 0 is a valid option for the function call. Here is my corrected version - if you make use of it - helpfile and function tips have to be adapted. Cheers. expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Author ........: Melba23 ; Modified.......: ; =============================================================================================================================== Func _ArrayExtract(Const ByRef $avArray, $iStart_Row = Default, $iEnd_Row = Default, $iStart_Col = Default, $iEnd_Col = Default) If $iStart_Row = Default Then $iStart_Row = 0 If $iStart_Col = Default Then $iStart_Col = 0 ;removed as this is not working with 0-based arrays ;If $iEnd_Row = Default Then $iEnd_Row = 0 ;If $iEnd_Col = Default Then $iEnd_Col = 0 If Not IsArray($avArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($avArray, $UBOUND_ROWS) - 1 If $iEnd_Row = Default Then $iEnd_Row = $iDim_1 If $iStart_Row < 0 Or $iEnd_Row < 0 Then Return SetError(3, 0, -1) If $iStart_Row > $iDim_1 Or $iEnd_Row > $iDim_1 Then Return SetError(3, 0, -1) If $iStart_Row > $iEnd_Row Then Return SetError(4, 0, -1) Switch UBound($avArray, $UBOUND_DIMENSIONS) Case 1 Local $aRetArray[$iEnd_Row - $iStart_Row + 1] For $i = 0 To $iEnd_Row - $iStart_Row $aRetArray[$i] = $avArray[$i + $iStart_Row] Next Return $aRetArray Case 2 Local $iDim_2 = UBound($avArray, $UBOUND_COLUMNS) - 1 If $iEnd_Col = Default Then $iEnd_Col = $iDim_2 If $iStart_Col < 0 Or $iEnd_Col < 0 Then Return SetError(5, 0, -1) If $iStart_Col > $iDim_2 Or $iEnd_Col > $iDim_2 Then Return SetError(5, 0, -1) If $iStart_Col > $iEnd_Col Then Return SetError(6, 0, -1) If $iStart_Col = $iEnd_Col Then Local $aRetArray[$iEnd_Row - $iStart_Row + 1] Else Local $aRetArray[$iEnd_Row - $iStart_Row + 1][$iEnd_Col - $iStart_Col + 1] EndIf For $i = 0 To $iEnd_Row - $iStart_Row For $j = 0 To $iEnd_Col - $iStart_Col If $iStart_Col = $iEnd_Col Then $aRetArray[$i] = $avArray[$i + $iStart_Row][$j + $iStart_Col] Else $aRetArray[$i][$j] = $avArray[$i + $iStart_Row][$j + $iStart_Col] EndIf Next Next Return $aRetArray Case Else Return SetError(2, 0, -1) EndSwitch Return 1 EndFunc ;==>_ArrayExtract Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted October 6, 2014 Moderators Solution Share Posted October 6, 2014 poolcat,Already reported and fixed in the latest Beta - but thanks for taking the time to post about it. 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...
poolcat Posted October 6, 2014 Author Share Posted October 6, 2014 @M23 Thanks for the info. Glad to be of help (although it wasnt this time) Cheers. 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