Die 1. Case bleibt nicht stehen wenn sie ausgefürt wurde sondern führt die 2 Case aus! Warum?

  • Funktion um eine Datenbank zu erweitern. Namen, Typenbezeichnung, und wo diese einsortiert wurden.
    Kein Bot!

    Ich denke das ist ein Bug^^.

    Spoiler anzeigen
    [autoit]


    If FileExists(@ScriptDir & '\Behälter.txt') Then
    Else
    $string4 = "Behälter.txt"
    FileWrite($string4, "Raum2," & @CRLF & "Seratum," & @CRLF & "Eelekroschrott," & @CRLF & "Füllbegölter," & @CRLF & "Trockenraum," & @CRLF & "Schuemer," & @CRLF & "Zusatz," & @CRLF & "SammelstelleR" )

    EndIf
    If FileExists(@ScriptDir & '\Infoanlagen.txt') Then
    Else
    $string5 = "Infoanlagen.txt"
    FileWrite($string5, "Zur reinen Information" )
    Dim $Angelegt = 1
    EndIf
    Dim $Angelegt = 0
    If FileExists(@ScriptDir & '\Find.txt') Then
    Else
    $string6 = "Find.txt"
    FileWrite($string6 , "set %findTypen "& @CRLF & "set %findena "& @CRLF & "set %findenc " & @CRLF & "set %findend " & @CRLF & "set %findene " & @CRLF & "set %findenf " & @CRLF & "set %findeng "& @CRLF & "set %findenh "& @CRLF & "set %findenj " & @CRLF & "set %findeni ")
    Dim $Angelegt = 1
    EndIf
    $string6 = "Find.txt"
    ;***************************************************
    ;******** Sortieren der Typen Items *****************
    #Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\busch.gaiaakku\desktop\skripte für pergon\sicherung der forms mit koda\form4includesortierenerweitern.kxf
    $Form2IS = GUICreate("Typen erweitern", 359, 233, 193, 125)
    GUISetFont(8, 800, 0, "MS Sans Serif")
    GUISetBkColor(0x316AC5)
    $Label2 = GUICtrlCreateLabel("Item Name: ", 25, 50, 86, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Input1IS = GUICtrlCreateInput("", 120, 50, 200, 21)
    $Input2IS = GUICtrlCreateInput("", 120, 90, 40, 21)

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

    $Label3 = GUICtrlCreateLabel("Typ:", 25, 90, 35, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("Ausnahmslos nur 3 Zeichen! Siehe Ettiket", 120, 120, 164, 17)
    $Combo1IS = GUICtrlCreateCombo("Behaelter", 120, 150, 200, 25)
    If FileExists(@ScriptDir & '\Behälter.txt') Then
    $file1T = FileOpen ( "Behälter.txt", 0 )
    If $file1T = -1 Then
    MsgBox(0, "Error", "Kann Datei nicht Öffnen!")
    Exit
    EndIf
    $AllLines1T = ""
    While 1
    $line1T = FileReadLine($file1T)
    If @error = -1 Then
    StringTrimRight($AllLines1T, 1)
    ExitLoop
    EndIf
    $AllLines1T &= $line1T &"|"
    Dim $AllLines21T = $AllLines1T
    WEnd
    Else
    MsgBox(4096,"Warnung" , "Behälter.txt does NOT exists")
    EndIf
    GUICtrlSetData($Combo1IS, $AllLines21T)
    $Label5 = GUICtrlCreateLabel("Wohin?", 25, 150, 55, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Back = GUICtrlCreateButton("Back", 120, 180, 80, 25, 0)
    GUICtrlSetCursor (-1, 0)
    $Button2IS = GUICtrlCreateButton("Einfügen", 240, 180, 80, 25, 0)
    GUICtrlSetCursor (-1, 0)
    GUISetState(@SW_HIDE)
    #EndRegion ### END Koda GUI section ###
    ;******** Sortieren der Typen Ende ******************
    ;***************************************************
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button2IS
    MsgBox(64, "","Hier werden neueTypen aufgenommen. " )
    Dim $LB = "Labor"
    Dim $RB = "Raum2"
    Dim $SaB = "Seratum"
    Dim $EB = "Eelekroschrott"
    Dim $FB = "Füllbegölter"
    Dim $TB = "Trockenraum"
    Dim $SB = "Schuemer"
    Dim $ZB = "Zusatz"
    Dim $SoB = "SammelstelleR"
    $NamedesDings = GuiCtrlRead($Input1IS )
    $Typ = GuiCtrlRead($Input2IS )
    $TypG = StringUpper ( $Typ )
    $InhaltCombo1IS = GUICtrlRead ($Combo1IS )
    $FindF = FileOpen ( "Find.txt", 0 )
    If ($FindF = -1) Then
    MsgBox(0, "Error", "Kann Datei nicht Öffnen!")
    Exit
    EndIf
    If ( $InhaltCombo1IS == "Behaelter" ) Then
    MsgBox(64, "Hinweiß","Ich weiß nicht wohin ich das schreiben soll!" , 3 )
    ContinueCase
    EndIf
    Dim $Start = 1
    $AllLines1TF = ""
    While 1
    $line1TF = FileReadLine($FindF)
    If (@error = -1) Then
    StringTrimRight($AllLines1TF, 1)
    ExitLoop
    EndIf
    $pruefen = StringInStr ( $line1TF, $TypG , 0 )
    If ( $pruefen <> 0 ) Then
    MsgBox(0, "Hinweiß", "Diser Typ Existiert bereits! Existiert ein Wunsch? Dann wende dich an den Skripter.")
    ContinueCase
    EndIf
    $resultF = StringInStr ( $line1TF, "set %findTypen " )
    ;msgbox(0, "INFO", "hurahiura. "& $resultF & " " & $line1TF )
    If ( $resultF <> 0 ) Then
    Dim $TempF = $line1TF & "_" & $TypG
    $ErsatzF = StringReplace ( $TempF , " _" , " " )
    ;MsgBox(0, "Der neue set %findTypen= ", $ErsatzF)
    $retvalF = _ReplaceStringInFile($string6 , $line1TF, $ErsatzF )
    If ( $retvalF = -1 ) then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    If FileExists(@ScriptDir & '\Find.txt') Then
    $Find = FileOpen ( "Find.txt", 0 )
    If ($Find = -1) Then
    MsgBox(0, "Error", "Kann Datei nicht Öffnen!")
    Exit
    EndIf
    $Info = FileOpen ( "Infoanlagen.txt", 1 )
    If ($Info = -1) Then
    MsgBox(0, "Error", "Kann Datei nicht Öffnen!")
    Exit
    EndIf
    FileWrite($Info, @CRLF & $InhaltCombo1IS & " enthält " & $NamedesDings & " _" & $TypG)
    FileClose($Info)
    $AllLinesFind = ""
    While 1
    $lineFind = FileReadLine($Find)
    ;MsgBox(0, "Der neue String", $lineFind )
    If @error = -1 Then
    StringTrimRight($AllLinesFind, 1)
    ExitLoop
    EndIf
    ;set %findTypen
    ;MsgBox(0, "Der neue String", $lineFind)
    If ( $LB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findena " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If ($retval = -1) then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    ContinueCase
    EndIf
    EndIf
    EndIf
    If ( $RB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findenc " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If $retval = -1 then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    ContinueCase
    EndIf
    EndIf
    EndIf
    If ( $SaB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findend " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If ($retval = -1) then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    ContinueCase
    EndIf
    EndIf
    EndIf
    If ( $EB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findene " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If $retval = -1 then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    ContinueCase
    EndIf
    EndIf
    EndIf
    If ( $FB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findenf " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If ($retval = -1) then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    ContinueCase
    EndIf
    EndIf
    EndIf
    If ( $TB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findeng " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If $retval = -1 then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    ContinueCase
    EndIf
    EndIf
    EndIf
    If ( $SB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findenh " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If $retval = -1 then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    ContinueCase
    EndIf
    EndIf
    EndIf
    If ( $ZB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findenj " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If ($retval = -1) then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    ContinueCase
    EndIf
    EndIf
    EndIf
    If ( $SoB == $InhaltCombo1IS ) Then
    $result = StringInStr ( $lineFind, "set %findeni " )
    If ( $result <> 0 ) Then
    Dim $Temp = $lineFind & "_" & $TypG
    $Ersatz = StringReplace ( $Temp , " _" , " " )
    ;MsgBox(0, "Der neue String", $Ersatz)
    $retval = _ReplaceStringInFile($string6 , $lineFind, $Ersatz )
    If ( $retval = -1 )then
    msgbox(0, "ERROR", "Es konte nicht ersetzt werden in File: " & $string6 & " Error: " & @error)
    exit
    Else
    msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.")
    FileClose($Find)
    EndIf
    EndIf
    EndIf
    WEnd
    Else
    MsgBox(4096,"Warnung" , "Find.txt.txt does NOT exists")
    EndIf
    EndIf
    EndIf
    WEnd

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

    Case $backC
    GUISetState (@SW_HIDE, $Form3C)
    GUISetState (@SW_SHOW, $einrichten )
    EndSwitch
    WEnd

    [/autoit]
  • Das problem Wenn ich auf den Button $Button2IS klicke wird alles nach plan aus gefürht. Das ist gut. Doch dan Wenn die meldung msgbox(0, "INFO", "Die Datenbank wurde Aktualisiert.") komt werden die unteren Case $back mit ausgefürt obwohl ich die Nicht gedrückt habe.

  • Hi,

    ich denke das hat mit Deinen ContinueCase zu tun:

    Abort the current case and continue a case into the next case in a Select or Switch block.

    Vielleicht meinst Du ein ContinueLoop, damit er wieder in die While Schleife zurückspringt.

    ;-))
    Stefan

  • Wenn ich das Cuntuinecase weglasse dann wird doch der rest nicht ausgeführt richtig? Sagen wir mal ich wollte damit die case beenden doch die aktielle GUI beibehalten.

  • Hi,

    hiermal 3 Case Schleifen, um das Problem zu verdeutlichen:

    Spoiler anzeigen
    [autoit]

    $i = 1
    ;jeder Case Fall nur einmal
    While $i < 4
    Switch $i
    Case $i = 1
    ;Code
    Msgbox (0,"Case " & $i, "Case 1" )
    Case $i = 2
    ;Code
    Msgbox (0,"Case " & $i, "Case 2" )
    Case $i = 3
    ;Code
    Msgbox (0,"Case " & $i, "Case 3")
    EndSwitch
    $i += 1
    WEnd

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

    $i = 1

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

    ;Diesmal nur Case Fall 1 + 3, da eine Case Schleife erzeugt wurde
    While $i < 4
    Switch $i
    Case $i = 1
    ;Code
    Msgbox (0,"Case " & $i, "Case 1")
    ContinueCase
    Case $i = 2
    ;Code
    Msgbox (0,"Case " & $i, "Case 2")
    ContinueCase
    Case $i = 3
    ;Code
    Msgbox (0,"Case " & $i, "Case 3")
    ContinueCase
    EndSwitch
    $i += 1
    WEnd

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

    $i = 1

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

    ;Alle Case Fälle werden mehrmals durchlaufen
    While $i < 4
    Switch $i
    Case $i = 1
    ;Code
    Msgbox (0,"Case " & $i, "Case 1")
    ContinueCase
    Case $i = 2
    ;Code
    Msgbox (0,"Case " & $i, "Case 2")
    ContinueCase
    Case $i = 3
    ;Code
    Msgbox (0,"Case " & $i, "Case 3")
    EndSwitch
    $i += 1
    WEnd

    [/autoit]

    ;-))
    Stefan