Frage zu einer Fehlermeldung

  • Hallo zusammen

    Und zwar habe ich ein Script geschrieben welches einen Text ausliest und in einen neuen hinein schreibt.
    Es funktioniert auch soweit ganz gut, in der neuen .txt Datei fehlt lediglich die letzte Zeile und dann bricht das Script ab und gibt mir diese Fehlermeldung

    Spoiler anzeigen

    C:\Users\ScarfacePH\Desktop\neu.au3 (434) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
    WEnd
    WEnd^ ERROR


    Kann mir da bitte einer weiterhelfen

    MfG

    ScarfacePH

    Einmal editiert, zuletzt von ScarfacePH (11. April 2010 um 23:09)

  • Hallo ScarfacePH,

    poste doch bitte das dazugehörige Skript. Die Fehlermeldung weist normalerweise darauf hin, dass du ein Array-Element ansprichst, das nicht exisitiert,

    mfg (Auto)Bert

  • ich rate mal: in zeile 434 steht hinterm WEnd noch irgendwas oder irgendeine variable ist falsch deklariert, nur ohne code kann man nicht viel zu sagen(ich zu mindestens). ?(

    Mfg. PCKing


    Mein PC

    CPU: AMD FX 8350 8x4.00GHz
    Ram: 8GB DDR3
    Grafikkarte: Nvidia Geforce GTX 960 (4GB)
    Festplatten: 500GB SSD 1TB HDD
    Laufwerk: Blueray RW+ Brenner

  • Dass ich ein Array aufrufe dessen Größe ich anscheinend überschreite ist mir klar jedoch gibt die Fehlermeldung sonst dass überschrittene Array an und nicht Wend ich weiß halt dadurch nicht genau welches Array und wo es bugt. Dachte das Problem könnte sich theoretisch lösen ohne Script aber kein Problem hier ist es

    Danke schon einmal im voraus.

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.3.4.0
    Author: ScarfacePH

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

    Script Function:
    Template AutoIt script.

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

    #ce ----------------------------------------------------------------------------

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

    #include <file.au3>
    #Include <String.au3>
    Dim $aRecords

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

    $file = FileOpen("test2.txt", 1)
    $file2 = FileOpen("test.txt", 0)
    $Lese = _FileReadToArray("test.txt",$aRecords)

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

    $pl0 = "Text 1"
    $pl1 = "Text 2"
    $pl2 = "Text 3"
    $pl3 = "Text 4"
    $pl4 = "Text 5"
    $pl5 = "Text 6"
    $pl6 = "Text 7"
    $pl7 = "Text 8"
    $pl8 = "Text 9"

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

    ; Prüfen, ob Datei im Schreibmodus geöffnet ist
    If $file = -1 Then
    MsgBox(0, "Fehler", "Die Datei konnte nicht geöffnet werden.")
    Exit
    EndIf

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

    If Not $Lese Then
    MsgBox(4096,"Error", " Fehler beim Einlesen der Datei Fehler:" & @error)
    Exit
    EndIf
    If $Lese Then
    MsgBox(4096,"ok", "kein Fehler beim Einlesen der Datei Fehler:" & @error)
    EndIf

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

    For $x = 1 to $aRecords[0]
    While StringInStr($aRecords[$x], "Herr") ; Eintrag ist vorhanden
    FileWriteLine($file, "1 |" & $aRecords[$x]) ; was immer du dann machen willst
    $i = 1

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

    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl0) Then
    $pos0 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1
    ExitLoop
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos0 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl0) Then
    $x = $x + 1
    $i = $i + 1
    EndIf

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

    WEnd
    $i = 1
    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl1) Then
    $pos1 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1

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

    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl1) Then
    $x = $x + 1
    $i = $i + 1
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos1 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    WEnd
    $i = 1
    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl2) Then
    $pos2 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1

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

    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl2) Then
    $x = $x + 1
    $i = $i + 1
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos2 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    WEnd
    $i = 1
    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl3) Then
    $pos3 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1

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

    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl3) Then
    $x = $x + 1
    $i = $i + 1
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos3 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    WEnd
    $i = 1
    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl4) Then
    $pos4 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1

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

    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl4) Then
    $x = $x + 1
    $i = $i + 1
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos4 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    WEnd
    $i = 1
    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl5) Then
    $pos5 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1

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

    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl5) Then
    $x = $x + 1
    $i = $i + 1
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos5 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    WEnd
    $i = 1
    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl6) Then
    $pos6 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1

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

    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl6) Then
    $x = $x + 1
    $i = $i + 1
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos6 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    WEnd
    $i = 1
    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl7) Then
    $pos7 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1

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

    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl7) Then
    $x = $x + 1
    $i = $i + 1
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos7 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    WEnd
    $i = 1
    While $x < $aRecords[0]

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

    If StringInStr($aRecords[$x], $pl8) Then
    $pos8 = StringSplit($aRecords[$x], " ")
    $x = $x - $i + 1

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

    ExitLoop
    EndIf
    If Not StringInStr($aRecords[$x], $pl8) Then
    $x = $x + 1
    $i = $i + 1
    EndIf
    If $i = 40 Then
    $x = $x - $i + 1
    $pos8 = StringSplit("bestellt ein", " ")
    ExitLoop
    EndIf
    WEnd

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

    $erg1 = StringSplit($aRecords[$x], ":")

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

    If StringInStr($aRecords[$x], $erg1[1]) Then

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

    If $erg1[1] = $pos0[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl0) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl0) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    If $erg1[1] = $pos1[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl1) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl1) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    If $erg1[1] = $pos2[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl2) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl2) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    If $erg1[1] = $pos3[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl3) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl3) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    If $erg1[1] = $pos4[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl4) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl4) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    If $erg1[1] = $pos5[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl5) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl5) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    If $erg1[1] = $pos6[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl6) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl6) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    If $erg1[1] = $pos7[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl7) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl7) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    If $erg1[1] = $pos8[3] Then
    $z = 1

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

    While 1

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

    If StringInStr($aRecords[$x],$pl8) Then
    FileWriteLine($file, "3 |"& $aRecords[$x])
    $RegEx = StringRegExp($aRecords[$x],".+\[(.+)\].+",3)
    If isArray($RegEx) = True Then FileWriteLine($file, "4 |"& $RegEx[0])
    $x = $x - $z + 1
    ExitLoop
    EndIf
    If not StringInStr($aRecords[$x],$pl8) Then
    $x = $x + 1
    $z = $z + 1
    EndIf
    WEnd
    EndIf

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

    EndIf

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

    If Not StringInStr($aRecords[$x], $erg1) Then
    $x = $x + 1
    EndIf

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

    WEnd

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

    Next

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

    FileClose($file)
    MsgBox(4096,"Fertig", "Datei fertig ausgelesen")
    Exit

    [/autoit]

    Einmal editiert, zuletzt von ScarfacePH (11. April 2010 um 20:14)

  • Nein, es weiß ja auch niemand was dein Script machen soll weil es so geordnet und übersichlich ist wie nach einem Obfuscator durchlauf. :rofl:
    Das lässt sich doch mit Sicherheit auch einfacher lösen als mit so vielen, ziemlich ähnlichen, Endlosschleifen. ;)

  • hab ich anfangs auch geglaubt das es einfacher geht aber nach langem hin und her war das der einzige weg um die Daten korrekt auszulesen

    Deswegen auch am Anfang der Versuch das Problem theoretisch zu lösen ohne Script. Hab mir schon gedacht das da bei der Ordnung ohne Kommis keiner so schnell hintersteigt.

    Bei mir ist das alles auch schön geschachtelt aber hab da noch so meine Probleme beim anständigen posten

    Hat den Jemand eine theoretische Lösung Betreff der Fehlermeldung bezogen auf das Wend?

  • Zitat


    Hat den Jemand eine theoretische Lösung Betreff der Fehlermeldung bezogen auf das Wend?


    Wieso? Die Fehlermeldung besagt, dass du die Arraygröße überschritten hast. ;)
    z.B.

    [autoit]

    Dim $Array[10]
    $Array[10] = "Test"

    [/autoit]


    Erzeugt den gleichen Fehler, da ein Array 0 basiert ist und somit nur bis zum Item 9 geht.