Wiederholung nur wenn etwas passiert

  • also hallo erstmal..ich habe laange nicht mehr mit autoit gearbeitet wollte wieder i.etwas schwachsinniges basteln :D
    also habe ich mir einen enscheider gebastelt :P

    Spoiler anzeigen
    [autoit]

    $comp = Random(1,100,1)
    ; Script Start - Add your code below here
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Enscheider", 252, 111, 192, 124)
    $Button1 = GUICtrlCreateButton("ja/nein", 32, 24, 89, 25)
    $Button2 = GUICtrlCreateButton("ja/nein/vielleicht", 120, 24, 89, 25)
    $Button3 = GUICtrlCreateButton("1-10", 32, 46, 89, 25)
    $Button4 = GUICtrlCreateButton("1-100", 119, 46, 89, 25)
    $button6 = GUICtrlCreateButton("Spiel!", 32, 68, 178, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Button1
    $ant=Random(1,2,1)
    if $ant = 1 Then
    Msgbox(0,"Antwort","JA")
    EndIf
    IF $ant = 2 Then
    Msgbox(0,"Antwort","Nein")
    EndIf
    case $Button2
    $ant2=Random(1,3,1)
    if $ant2 = 1 Then
    Msgbox(0,"Antwort","JA")
    EndIf
    if $ant2 = 2 Then
    Msgbox(0,"Antwort","NEIN")
    EndIf
    if $ant2 = 3 Then
    Msgbox(0,"Antwort","VIELLEICHT")
    EndIf
    case $Button3
    $zahl=Random(1,10,1)
    Msgbox(0,"Antwort",$zahl)
    case $Button4
    $zahl2=Random(1,100,1)
    Msgbox(0,"Antwort",$zahl2)
    case $button6
    $you = InputBox("Deine Zahl!","errate die zahl die ich mir ausgedacht habe!")
    IF $you < $comp Then
    Msgbox(0,"falsch!","Die gesuchte zahl ist größer!")
    EndIf
    If $you > $comp Then
    Msgbox(0,"falsch!","Die gesuchte zahl ist kleiner!")
    EndIf
    If $you = $comp Then
    Msgbox(0,"Richtig!","Super,du hast die zahl erraten!")
    $comp = Random(1,100,1)
    EndIf
    EndSwitch
    WEnd

    [/autoit]

    so jetzt zum "case $button6" teil!
    ich will das wenn er die zahl falsch eingegeben hat er den user noch einmal fragt welche zahl er rät!

    also sagen wir ich gebe 50 als zahl ein!
    dann kommt die nachricht ...falsch zu klein....dann will ich das er mich noch einmal fragt welche zahl ich jetzt eingeben will...bis ich es richtig habe!....


    Danke für jede hilfe

    Einmal editiert, zuletzt von vassilis (25. Mai 2010 um 18:16)

  • Mach es doch so ;).

    Spoiler anzeigen
    [autoit]

    $comp = Random(1, 100, 1)
    $you = InputBox("Deine Zahl!", "errate die zahl die ich mir ausgedacht habe!")
    While 1
    If $you < $comp Then
    MsgBox(0, "falsch!", "Die gesuchte zahl ist größer!")
    EndIf
    If $you > $comp Then
    MsgBox(0, "falsch!", "Die gesuchte zahl ist kleiner!")
    EndIf
    If $you = $comp Then
    MsgBox(0, "Richtig!", "Super,du hast die zahl erraten!")
    ExitLoop
    EndIf
    WEnd

    [/autoit]
  • mach es so:

    Spoiler anzeigen
    [autoit]

    $comp = Random(1, 100, 1)
    While 1
    $you = InputBox("Deine Zahl!", "errate die zahl die ich mir ausgedacht habe!")
    Select
    Case $you < $comp
    MsgBox(0, "falsch!", "Die gesuchte zahl ist größer!")
    Case $you > $comp
    MsgBox(0, "falsch!", "Die gesuchte zahl ist kleiner!")
    Case $you = $comp
    MsgBox(0, "Richtig!", "Super,du hast die zahl erraten!")
    ExitLoop
    Case Else ;kann nicht vorkommen
    MsgBox(0, "Achtung", "Ich schummle gerade!")
    EndSelect
    WEnd

    [/autoit]

    name22 die InptBox gehört in die while schleife

    mfg (Auto)Bert