- Offizieller Beitrag
Da vorhin die Frage im Forum zu einer solchen Funktion war, hier ist sie:
_Array2DDelete(ByRef $ARRAY, $iDEL)
Löscht aus einem 1D/2D -Array eine Zeile an der vorgegebenen Indexposition.
Spoiler anzeigen
;----------------------------------------------------------------------------------------------------------------------
; Fuction _Array2DDelete(ByRef $ARRAY, $iDEL)
;
; Description Delete one row on a given index in an 1D/2D -Array
;
; Parameter $ARRAY the array, where one row will deleted
; $iDEL Row-Index to delete
;
; Return Succes -1 ByRef $ARRAY
; Failure 0 set @error = 1; given array are not array
; set @error = 2; index is out of range
;
; Author BugFix ([email='bugfix@autoit.de'][/email])
;----------------------------------------------------------------------------------------------------------------------
Func _Array2DDelete(ByRef $ARRAY, $iDEL)
If ( Not IsArray($ARRAY) ) Then
SetError(1)
Return 0
EndIf
If ( $iDEL < 0 ) Or ( $iDEL > UBound($ARRAY)-1 ) Then
SetError(2)
Return 0
EndIf
Local $UBound2nd = UBound($ARRAY,2)
If @error = 2 Then
Local $arTmp[UBound($ARRAY)-1]
$k = 0
For $i = 0 To UBound($ARRAY)-1
If $i <> $iDEL Then
$arTmp[$k] = $ARRAY[$i]
$k += 1
EndIf
Next
Else
Local $arTmp[UBound($ARRAY)-1][$UBound2nd]
$k = 0
For $i = 0 To UBound($ARRAY)-1
If $i <> $iDEL Then
For $l = 0 To $UBound2nd-1
$arTmp[$k][$l] = $ARRAY[$i][$l]
Next
$k += 1
EndIf
Next
EndIf
$ARRAY = $arTmp
Return -1
EndFunc