Hey.
Mal wieder ne 2D Array Funktion die ich mir schnell zusammengeschrieben habe vllt braucht sie ja jemand.
Spoiler anzeigen
; #FUNCTION# ====================================================================================================================
; Name...........: _2DArrayAdd
; Description ...: Adds a specified value at the end of an existing array.
; Syntax.........: _2DArrayAdd(ByRef $avArray, $vValue, $sDel = "|")
; Parameters ....: $avArray - Array to modify
; $vValue - Value to add
; $sDel - delimiters to split the 2D elements default is |
; Return values .: Success - Index of last added item
; Failure - -1, sets @error
; |1 - $avArray is not an array
; |2 - $avArray is not a 2 dimensional array
; |3 - splitted Value <> Ubound of the 2 dimension of the Array or in $sValue is no delimiters
; Author ........: Dater
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........: http://www.Autoit.de
; Example .......:
; ===============================================================================================================================
Func _2DArrayAdd(ByRef $avArray, $sValue, $sDel = "|")
If Not IsArray($avArray) Then Return SetError(1, 0, -1)
If UBound($avArray, 0) <> 2 Then Return SetError(2, 0, -1)
Local $aValue = StringSplit($sValue,$sDel,2)
Local $iUBound_D1 = UBound($avArray,1)
Local $iUBound_D2 = UBound($avArray,2)
If Not IsArray($aValue) Or UBound($aValue) <> $iUBound_D2 Then Return SetError(3, 0, -1)
[/autoit] [autoit][/autoit] [autoit]ReDim $avArray[$iUBound_D1 + 1][$iUBound_D2]
For $i = 0 To UBound($aValue)-1
$avArray[$iUBound_D1][$i] = $aValue[$i]
Next
Return $iUBound_D1
EndFunc ;==>_2DArrayAdd
Und noch ein bsp. dazu:
Spoiler anzeigen
#include <Array.au3>
[/autoit] [autoit][/autoit] [autoit]Global $aArray[2][3] = [["Row 0 col 0","Row 0 col 1","Row 0 col 2"],["Row 1 col 0","Row 1 col 1","Row 1 col 2"]]
_ArrayDisplay($aArray)
_2DArrayAdd($aArray, "Row 2 col 0|Row 2 col 1|Row 2 col 2")
_ArrayDisplay($aArray)
_2DArrayAdd($aArray, "Row 3 col 0|Row 3 col 1|Row 3 col 2")
_ArrayDisplay($aArray)
; #FUNCTION# ====================================================================================================================
; Name...........: _2DArrayAdd
; Description ...: Adds a specified value at the end of an existing array.
; Syntax.........: _2DArrayAdd(ByRef $avArray, $vValue, $sDel = "|")
; Parameters ....: $avArray - Array to modify
; $vValue - Value to add
; $sDel - delimiters to split the 2D elements default is |
; Return values .: Success - Index of last added item
; Failure - -1, sets @error
; |1 - $avArray is not an array
; |2 - $avArray is not a 2 dimensional array
; |3 - splitted Value <> Ubound of the 2 dimension of the Array or in $sValue is no delimiters
; Author ........: Dater
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........: http://www.Autoit.de
; Example .......:
; ===============================================================================================================================
Func _2DArrayAdd(ByRef $avArray, $sValue, $sDel = "|")
If Not IsArray($avArray) Then Return SetError(1, 0, -1)
If UBound($avArray, 0) <> 2 Then Return SetError(2, 0, -1)
Local $aValue = StringSplit($sValue,$sDel,2)
Local $iUBound_D1 = UBound($avArray,1)
Local $iUBound_D2 = UBound($avArray,2)
If Not IsArray($aValue) Or UBound($aValue) <> $iUBound_D2 Then Return SetError(3, 0, -1)
[/autoit] [autoit][/autoit] [autoit]ReDim $avArray[$iUBound_D1 + 1][$iUBound_D2]
For $i = 0 To UBound($aValue)-1
$avArray[$iUBound_D1][$i] = $aValue[$i]
Next
Return $iUBound_D1
EndFunc ;==>_2DArrayAdd
mfg Darter