Taschenrechner

  • Habe mit einem kleinen Taschenrechner begonnen. Jedoch komme ich beim "=" nicht mehr weiter. Was muss ich da eintippen, damit die Zahlen zusammengerechnet werden und oben als Ergebnis rauskommen? Am besten sollte alles andere überschrieben werden. Also nicht: 5+5=10

    Hier das bisherige Script:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 311, 308, 192, 124)
    $Label1 = GUICtrlCreateLabel("", 40, 24, 228, 36)
    GUICtrlSetBkColor($Label1, 0xFFFFFF)
    GUICtrlSetFont($Label1, 21)
    $Button1 = GUICtrlCreateButton("1", 48, 80, 41, 41, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("2", 104, 80, 41, 41, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("3", 160, 80, 41, 41, $WS_GROUP)
    $Button4 = GUICtrlCreateButton("4", 48, 136, 41, 41, $WS_GROUP)
    $Button5 = GUICtrlCreateButton("5", 104, 136, 41, 41, $WS_GROUP)
    $Button6 = GUICtrlCreateButton("6", 160, 136, 41, 41, $WS_GROUP)
    $Button7 = GUICtrlCreateButton("7", 48, 192, 41, 41, $WS_GROUP)
    $Button8 = GUICtrlCreateButton("8", 104, 192, 41, 41, $WS_GROUP)
    $Button9 = GUICtrlCreateButton("9", 160, 192, 41, 41, $WS_GROUP)
    $Button10 = GUICtrlCreateButton("0", 48, 248, 41, 41, $WS_GROUP)
    $Button11 = GUICtrlCreateButton("/", 216, 80, 41, 41, $WS_GROUP)
    $Button12 = GUICtrlCreateButton("*", 216, 136, 41, 41, $WS_GROUP)
    $Button13 = GUICtrlCreateButton("-", 216, 192, 41, 41, $WS_GROUP)
    $Button14 = GUICtrlCreateButton("+", 216, 248, 41, 41, $WS_GROUP)
    $Button15 = GUICtrlCreateButton(".", 104, 248, 41, 41, $WS_GROUP)
    $Button16 = GUICtrlCreateButton("=", 160, 248, 41, 41, $WS_GROUP)
    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
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "1")
    Case $Button2
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "2")
    Case $Button3
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "3")
    Case $Button4
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "4")
    Case $Button5
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "5")
    Case $Button6
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "6")
    Case $Button7
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "7")
    Case $Button8
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "8")
    Case $Button9
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "9")
    Case $Button10
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "0")
    Case $Button11
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "/")
    Case $Button12
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "*")
    Case $Button13
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "-")
    Case $Button14
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "+")
    Case $Button15
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & ".")
    Case $Button16
    ;~ Was muss hier rein?

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

    EndSwitch
    WEnd

    [/autoit]

    mfG
    Charlie


    Edit: Hier der fertige Rechner: Klick mich
    Charlie

    Einmal editiert, zuletzt von Charlie (3. August 2009 um 21:51)

  • Hallo,

    Zitat

    ;~ Was muss hier rein?

    [autoit]

    GUICtrlSetData( $label1, Execute( GUICtrlRead( $label1 ) ) )

    [/autoit]


    muss nicht unbedingt, aber wirft ein Ergebnis aus^^

    ciao
    Andy

    ciao
    Andy


    "Schlechtes Benehmen halten die Leute doch nur deswegen für eine Art Vorrecht, weil keiner ihnen aufs Maul haut." Klaus Kinski
    "Hint: Write comments after each line. So you can (better) see what your program does and what it not does. And we can see what you're thinking what your program does and we can point to the missunderstandings." A-Jay

    Wie man Fragen richtig stellt... Tutorial: Wie man Script-Fehler findet und beseitigt...X-Y-Problem

    Einmal editiert, zuletzt von Andy (3. August 2009 um 20:51)

  • Hi,

    Zitat

    Da sollte aber noch ein Set taste her =)

    das verstehe ich nicht, aber eine C-Taste( in Rot^^) wäre noch schön ;)
    Andy

  • Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 311, 308, 192, 124)
    $Label1 = GUICtrlCreateLabel("", 40, 9, 228, 36)
    GUICtrlSetBkColor($Label1, 0xFFFFFF)
    GUICtrlSetFont($Label1, 21)
    $Button1 = GUICtrlCreateButton("1", 48, 80, 41, 41, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("2", 104, 80, 41, 41, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("3", 160, 80, 41, 41, $WS_GROUP)
    $Button4 = GUICtrlCreateButton("4", 48, 136, 41, 41, $WS_GROUP)
    $Button5 = GUICtrlCreateButton("5", 104, 136, 41, 41, $WS_GROUP)
    $Button6 = GUICtrlCreateButton("6", 160, 136, 41, 41, $WS_GROUP)
    $Button7 = GUICtrlCreateButton("7", 48, 192, 41, 41, $WS_GROUP)
    $Button8 = GUICtrlCreateButton("8", 104, 192, 41, 41, $WS_GROUP)
    $Button9 = GUICtrlCreateButton("9", 160, 192, 41, 41, $WS_GROUP)
    $Button10 = GUICtrlCreateButton("0", 48, 248, 41, 41, $WS_GROUP)
    $Button11 = GUICtrlCreateButton("/", 216, 80, 41, 41, $WS_GROUP)
    $Button12 = GUICtrlCreateButton("*", 216, 136, 41, 41, $WS_GROUP)
    $Button13 = GUICtrlCreateButton("-", 216, 192, 41, 41, $WS_GROUP)
    $Button14 = GUICtrlCreateButton("+", 216, 248, 41, 41, $WS_GROUP)
    $Button15 = GUICtrlCreateButton(".", 104, 248, 41, 41, $WS_GROUP)
    $Button16 = GUICtrlCreateButton("=", 160, 248, 41, 41, $WS_GROUP)
    $Button17 = GUICtrlCreateButton("C", 48, 50, 41, 20, $WS_GROUP)
    GUICtrlSetBkColor(-1, 0xFF0000)
    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
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "1")
    Case $Button2
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "2")
    Case $Button3
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "3")
    Case $Button4
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "4")
    Case $Button5
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "5")
    Case $Button6
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "6")
    Case $Button7
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "7")
    Case $Button8
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "8")
    Case $Button9
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "9")
    Case $Button10
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "0")
    Case $Button11
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "/")
    Case $Button12
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "*")
    Case $Button13
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "-")
    Case $Button14
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & "+")
    Case $Button15
    GUICtrlSetData($Label1, GUICtrlRead($Label1) & ".")
    Case $Button16
    ;~ Was muss hier rein?
    GUICtrlSetData( $label1, Execute( GUICtrlRead( $label1 ) ) )
    Case $Button17
    GUICtrlSetData($Label1, "")
    EndSwitch
    WEnd

    [/autoit]

    Ergebnis und rote (C)leartaste^^

  • Danke vielmal für eure Hilfe :D

    Da kommen schon noch einige Tasten hin. Werde das fertige Ergebnis dann auch mal hier posten :)

    mfG
    Charlie

  • so könnte man es machen zu deiner frage im chat


    [autoit]

    $pfad = ;hier den pfad von script angeben

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

    $Button = GUICtrlCreateButton("")
    GUICtrlSetOnEvent(-1, "new")

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

    Func new()
    Exit
    Run ($pfad)
    EndFunc

    [/autoit]
  • Hallo?
    Logisch denken, Exit beendet das Script an dieser Stelle und es läuft nicht mehr weiter O.o

    Wie soll dann noch der Run Befehl klappen?

  • Hallo?
    Logisch denken, Exit beendet das Script an dieser Stelle und es läuft nicht mehr weiter O.o

    Wie soll dann noch der Run Befehl klappen?

    ya sry dann vorher run und dann exit war mein fehler sry