;---------------------------------------------------------------------------------------------------------------------- ; Function _SubArray2DSetEntry(ByRef $ARRAY, $Entry, $SubRow, $ParentRow [, $SubCol=-1 [, $ParentCol=-1]) ; ; Description For Array with Array as entry you set the determined entry ; Works with any occurences in 2nd Dimension (parent array and sub-array too) ; Works also with 1D-Array ; ; Parameter $ARRAY Given array with array as entrys ; $Entry Value you want to set in the sub-array ; $SubRow 0-based row -index of the entry inside the sub-array, you want to set ; $ParentRow 0-based row -index of parent-array ; optional $SubCol 0-based column -index of sub-array, (if exists) ; optional $ParentCol 0-based column -index of parent-array, (if exists) ; ; Return Succes -1 value is set ; Failure 0 and set @error ; @error = 1 given array is not array ; @error = 2 row -index for parent-array out of range ; @error = 3 col -index for parent-array out of range ; @error = 4 col -index for parent-array is given, but array is 1D ; @error = 5 row -index for sub-array out of range ; @error = 6 col -index for sub-array out of range ; @error = 7 col -index for sub-array is given, but array is 1D ; ; Author BugFix (bugfix@autoit.de) ;---------------------------------------------------------------------------------------------------------------------- Func _SubArray2DSetEntry(ByRef $ARRAY, $Entry, $SubRow, $ParentRow, $SubCol=-1, $ParentCol=-1) If (Not IsArray($ARRAY)) Then SetError(1) Return 0 EndIf If ($ParentRow < 0) Or ($ParentRow > UBound($ARRAY)-1) Then SetError(2) Return 0 EndIf Local $Ub2ndParent = UBound($ARRAY, 2) If @error Then If $ParentCol <> -1 Then SetError(4) Return 0 EndIf ElseIf ($ParentCol < -1) Or ($ParentCol > $Ub2ndParent-1) Then SetError(3) Return 0 EndIf Switch $ParentCol Case -1 Local $arSub = $ARRAY[$ParentRow] Case Else Local $arSub = $ARRAY[$ParentRow][$ParentCol] EndSwitch If ($SubRow < 0) Or ($SubRow > UBound($arSub)-1) Then SetError(5) Return 0 EndIf Local $Ub2ndSub = UBound($arSub, 2) If @error Then If $SubCol <> -1 Then SetError(7) Return 0 Else $arSub[$SubRow] = $Entry EndIf Else If ($SubCol < 0) Or ($SubCol > $Ub2ndSub) Then SetError(6) Return 0 Else $arSub[$SubRow][$SubCol] = $Entry EndIf EndIf Switch $ParentCol Case -1 $ARRAY[$ParentRow] = $arSub Case Else $ARRAY[$ParentRow][$ParentCol] = $arSub EndSwitch Return -1 EndFunc ;==>_SubArray2DSetEntry