Nur jeder 2te Array

  • Hallo,
    ich hab folgendes Problem, ich muss jedes 2te Array Ausgeben, wie mache ich das?
    Ich vermute mit einer For Schleife aber ich weiß nicht wie!

    [autoit]


    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    $Form2 = GUICreate("Form2", 188, 95, 210, 142)
    $Edit1 = GUICtrlCreateEdit("", 0, 0, 185, 89)
    GUICtrlSetData(-1, "foo" & @CRLF & "bar")
    GUISetState(@SW_SHOW)
    $Auswerten1 = GUICtrlRead($Edit1)
    MsgBox(0,"",$Auswerten1)
    $Auswerten2 = StringSplit($Auswerten1, @CRLF)
    ; Hier ist das Problem wenn ich $Auswerten2[2] mache kommt nichts, da soll es dann rüber gehen zu 3 dann zu 5 usw. For schleife?

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit][autoit][/autoit][autoit][/autoit]
  • Danke hat geklappt! Hier das fertige Script, auch wen es so keinen helfen wird (denke ich)

    [autoit]


    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    $Form2 = GUICreate("Form2", 188, 95, 210, 142)
    $Edit1 = GUICtrlCreateEdit("", 0, 0, 185, 89)
    GUICtrlSetData(-1, "foo" & @CRLF & "bar")
    GUISetState(@SW_SHOW)
    $Auswerten1 = GUICtrlRead($Edit1)
    MsgBox(0,"",$Auswerten1)
    $Auswerten2 = StringSplit($Auswerten1, @CRLF)
    For $i = 1 to UBound($auswerten2) -1 Step 2
    $Erg = $Auswerten2[$i]
    MsgBox(0,"",$Erg)
    next
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]


    Jetzt hab ich aber ein Problem, das ich das gleiche nochmal brauche aber das ich den Array dann auch mit

    [autoit]

    _ArrayDisplay()

    [/autoit]

    ausgeben kann.
    Danke schonmal!

  • Das Problem ist es soll jedes 2te Array speichern und mit Array Display ausgeben.


    daz msst du entweder jedes ungerade vor der Anzeige löschen oder jedes gerade Element in ein neues Array schreiben und dieses anzeigen. Hier ein Beispiel für die 2. Möglichkeit

    Spoiler anzeigen
    [autoit]

    #include <array.au3>
    #include <date.au3>
    #include <string.au3>
    #include <Array.au3>

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

    Dim $array[100][2]
    For $i = 0 To 99
    If not Mod($i , 2) Then
    $array[$i][0] = _StringRepeat(Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)), 18)
    $array[$i][1] = Random(1, 31, 1) & "." & Random(1, 12, 1) & "." & Random(1960, 2000, 1); Pseudo-Datum ohne Prüfung auf Existenz z.B.31.02.2010 durchaus möglich
    Else
    $array[$i][0] = "Schrott"
    $array[$i][1] = "Schrott"
    EndIf
    Next

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

    _ArrayDisplay($array)

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

    $j = int((UBound($array)+ 1)/2)
    dim $array2[$j][2]
    $j = 0
    for $i = 0 to UBound($array) -1 step 2
    $array2[$j][0] = $array[$i][0]
    $array2[$j][1] = $array[$i][1]
    $j += 1
    Next
    _ArrayDisplay($array2)

    [/autoit]

    mfg (Auto)Bert

  • Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <date.au3>
    #include <string.au3>
    #include <Array.au3>

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

    $Form2 = GUICreate("Form2", 188, 95, 210, 142)
    $Edit1 = GUICtrlCreateEdit("", 0, 0, 185, 89)
    GUICtrlSetData(-1, "foo" & @CRLF & "bar")
    GUISetState(@SW_SHOW)
    $Auswerten1 = GUICtrlRead($Edit1)
    MsgBox(0, "", $Auswerten1)
    $Auswerten2 = StringSplit($Auswerten1, @CRLF)
    For $i = 1 To UBound($Auswerten2) - 1 Step 2
    $Erg = $Auswerten2[$i]
    MsgBox(0, "", $Erg)
    Next
    $Erg1 = StringSplit($Auswerten1, @CRLF)
    For $i = 0 To 99
    If Not Mod($i, 2) Then
    $Erg1[$i] = _StringRepeat(Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)) & Chr(Random(65, 67, 1)), 18)
    $Erg1[$i] = Random(1, 31, 1) & "." & Random(1, 12, 1) & "." & Random(1960, 2000, 1); Pseudo-Datum ohne Prüfung auf Existenz z.B.31.02.2010 durchaus möglich
    Else
    $Erg1[$i] = "Schrott"
    $Erg1[$i] = "Schrott"
    EndIf
    Next
    _ArrayDisplay($Erg1)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]


    Bei mir kommt jedoch nichts dabei raus!

  • Hallo ProblemUser,

    ich habe mein Beispiel direkt in dein Testskript eingepflegt:

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <date.au3>
    #include <string.au3>

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

    #Include <GuiEdit.au3>
    #include <Array.au3>

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

    $Form2 = GUICreate("Form2", 400, 300, 210, 142)
    $Edit1 = GUICtrlCreateEdit("", 0, 0, 385, 265)
    $sData = ""
    For $i = 0 To 99
    If Not Mod($i, 2) Then
    $sData &= "Zeile: " & $i &@CRLF
    Else
    $sData &= "Schrott" &@CRLF
    EndIf
    Next
    GUICtrlSetData($Edit1,$sData)
    $idBtnAuswerten = GUICtrlCreateButton("&auswerten", 55, 270, 185, 28)

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

    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $idBtnAuswerten
    ConsoleWrite("rufe auf" & @CRLF)
    $Auswerten = GUICtrlRead($Edit1)
    $Auswerten2 = StringSplit($Auswerten, @CRLF,3)
    _ShowArray($Auswerten2)
    EndSwitch
    WEnd

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

    Func _ShowArray($array)
    ConsoleWrite("Aufruf erfolgt" & @CRLF)
    _ArrayDisplay($array)
    $j = Int((UBound($array) + 2) / 2)
    Dim $array2[$j]
    $j = 0
    For $i = 0 To UBound($array) - 1 Step 2
    $array2[$j] = $array[$i]
    $j += 1
    Next
    _ArrayDisplay($array2)
    EndFunc ;==>_ShowArray

    [/autoit]

    und die func zum Anzeigen auf einen Button gelegt,

    mfg (Auto)Bert