• Hey.
    Mal wieder ne 2D Array Funktion die ich mir schnell zusammengeschrieben habe vllt braucht sie ja jemand.

    Spoiler anzeigen
    [autoit]

    ; #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)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aValue = StringSplit($sValue,$sDel,2)
    Local $iUBound_D1 = UBound($avArray,1)
    Local $iUBound_D2 = UBound($avArray,2)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Return $iUBound_D1
    EndFunc ;==>_2DArrayAdd

    [/autoit]

    Und noch ein bsp. dazu:

    Spoiler anzeigen
    [autoit]

    #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)

    [/autoit] [autoit][/autoit] [autoit]

    ; #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)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aValue = StringSplit($sValue,$sDel,2)
    Local $iUBound_D1 = UBound($avArray,1)
    Local $iUBound_D2 = UBound($avArray,2)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Return $iUBound_D1
    EndFunc ;==>_2DArrayAdd

    [/autoit]

    mfg Darter

    Das finden von Rechtschreibfehlern muss sofort und unverzüglich dem Autor gemeldet werden. Das eigennützige Verwenden dieser Rechtschreibfehler ist strengstens untersagt und kann mit Freiheitsenzug bestraft werden.

  • jup hat man mir getern abend, nachdem ich fertig war auch mitgeteilt ^^

    Das finden von Rechtschreibfehlern muss sofort und unverzüglich dem Autor gemeldet werden. Das eigennützige Verwenden dieser Rechtschreibfehler ist strengstens untersagt und kann mit Freiheitsenzug bestraft werden.