Variable ausgeben die sich ändert

  • hey leute,
    ich hoffe ihr könnt mir diesesmal wieder helfen :)
    also ich habe eine rechenoperation die ich durchführe
    um zu zeigen was schritt für schritt dabei gerechnet wird will ich dem benutzer zeigen was der computer rechnet
    ich habe mehrere variablen die den wert enthalten (am ende halt die lösung) und will die variable ausgeben
    sie ändert sich aber ständig
    so nun mein problem
    ich habe z.b. 1 + 1 = $a
    jetzt will ich $a ausgeben
    und danach ändert sich a weiter weil damit gerechnet wird
    ausgegeben soll es aber in einer weitern koda designer box die sich öffnet wenn man auf einen anderen button drückt
    [spoiler]
    [autoit]
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=c:\users\patrick becker\desktop\form2.kxf
    $Form1_1 = GUICreate("Form1", 688, 423, 222, 124)
    $Input1 = GUICtrlCreateInput("", 8, 16, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 160, 16, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("", 304, 16, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 456, 16, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input5 = GUICtrlCreateInput("", 9, 80, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input6 = GUICtrlCreateInput("", 160, 80, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input7 = GUICtrlCreateInput("", 304, 80, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input8 = GUICtrlCreateInput("", 456, 80, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input9 = GUICtrlCreateInput("", 10, 144, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input10 = GUICtrlCreateInput("", 160, 144, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input11 = GUICtrlCreateInput("", 304, 144, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Input12 = GUICtrlCreateInput("", 456, 144, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $x = GUICtrlCreateLabel("x", 24, 227, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $y = GUICtrlCreateLabel("y", 248, 20, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Start = GUICtrlCreateButton("Start", 584, 16, 65, 49)
    $Hilfe = GUICtrlCreateButton("Hilfe", 584, 80, 65, 49)
    $a = GUICtrlCreateLabel("+", 136, 23, 22, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $v = GUICtrlCreateLabel("+", 280, 24, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $z = GUICtrlCreateLabel("z", 400, 19, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $c = GUICtrlCreateLabel("=", 432, 21, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label1 = GUICtrlCreateLabel("x", 104, 83, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("+", 136, 86, 22, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("y", 248, 84, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("z", 400, 91, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("=", 432, 93, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel("+", 279, 85, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label7 = GUICtrlCreateLabel("x", 104, 147, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label8 = GUICtrlCreateLabel("+", 136, 149, 22, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label9 = GUICtrlCreateLabel("y", 248, 148, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label10 = GUICtrlCreateLabel("+", 279, 150, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label11 = GUICtrlCreateLabel("z", 400, 147, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label12 = GUICtrlCreateLabel("=", 432, 149, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label13 = GUICtrlCreateLabel("x", 103, 23, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label14 = GUICtrlCreateLabel("y", 24, 292, 19, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label15 = GUICtrlCreateLabel("z", 22, 355, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label16 = GUICtrlCreateLabel("=", 72, 229, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label17 = GUICtrlCreateLabel("=", 72, 301, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $Label18 = GUICtrlCreateLabel("=", 72, 357, 20, 41)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $ErgebnissX = GUICtrlCreateLabel("", 120, 232, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $ErgebnissY = GUICtrlCreateLabel("", 120, 296, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    $ErgebnissZ = GUICtrlCreateLabel("", 120, 360, 81, 45)
    GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Start
    $xKoordinate1 = GUICtrlRead($Input1)
    $yKoordinate1 = GUICtrlRead($Input2)
    $zKoordinate1 = GUICtrlRead($Input3)
    $Ergebniss1 = GUICtrlRead($Input4)

    $xKoordinate2 = GUICtrlRead($Input5)
    $yKoordinate2 = GUICtrlRead($Input6)
    $zKoordinate2 = GUICtrlRead($Input7)
    $Ergebniss2 = GUICtrlRead($Input8)

    $xKoordinate3 = GUICtrlRead($Input9)
    $yKoordinate3 = GUICtrlRead($Input10)
    $zKoordinate3 = GUICtrlRead($Input11)
    $Ergebniss3 = GUICtrlRead($Input12)

    If $xKoordinate1 = 0 Then MsgBox(0, "Information","Die erste x-Koordinate darf nicht Null sein , da man sonst durch Null teilt!")
    If $xKoordinate1 = 0 Then Exit

    $x1 = $xKoordinate1
    $x2 = $xKoordinate2
    $x3 = $xKoordinate3
    $y1 = $yKoordinate1
    $y2 = $yKoordinate2
    $y3 = $yKoordinate3
    $z1 = $zKoordinate1
    $z2 = $zKoordinate2
    $z3 = $zKoordinate3
    $e1 = $Ergebniss1
    $e2 = $Ergebniss2
    $e3 = $Ergebniss3


    $y1 = $y1 / $x1
    $z1 = $z1 / $x1
    $e1 = $e1 / $x1
    $x1 = $x1 / $x1

    $x1 = $x1 * (-1) * $x2
    $y1 = $y1 *(-1) * $x2
    $z1 = $z1 *(-1) * $x2
    $e1 = $e1 * (-1) * $x2

    $x2 = $x1 + $x2
    $y2 = $y1 + $y2
    $z2 = $z1 + $z2
    $e2 = $e1 + $e2

    $y1 = $y1 / $x1
    $z1 = $z1 / $x1
    $e1 = $e1 / $x1
    $x1 = $x1 / $x1

    $x1 = $x1 * (-1) * $x3
    $y1 = $y1 *(-1) * $x3
    $z1 = $z1 *(-1) * $x3
    $e1 = $e1 * (-1) * $x3

    $x3 = $x1 + $x3
    $y3 = $y1 + $y3
    $z3 = $z1 + $z3
    $e3 = $e1 + $e3

    $y1 = $y1 / $x1
    $z1 = $z1 / $x1
    $e1 = $e1 / $x1
    $x1 = $x1 / $x1

    $z2 = $z2 / $y2
    $e2 = $e2 / $y2
    $y2 = $y2 / $y2

    $y2 = $y2 * (-1) * $y3
    $z2 = $z2 * (-1) * $y3
    $e2 = $e2 * (-1) * $y3

    $x3 = $x2 + $x3
    $y3 = $y2 + $y3
    $z3 = $z2 + $z3
    $e3 = $e2 + $e3

    $z2 = $z2 / $y2
    $e2 = $e2 / $y2
    $y2 = $y2 / $y2

    $e3 = $e3 / $z3
    $z3 = $z3 / $z3

    $y2 = $y2 * (-1) * $y1
    $z2 = $z2 * (-1) * $y1
    $e2 = $e2 * (-1) * $y1

    $x1 = $x1 + $x2
    $y1 = $y1 + $y2
    $z1 = $z1 + $z2
    $e1 = $e1 + $e2

    $z2 = $z2 / $y2
    $e2 = $e2 / $y2
    $y2 = $y2 / $y2

    $z3 = $z3 * (-1) * $z1
    $e3 = $e3 * (-1) * $z1

    $z1 = $z1 + $z3
    $e1 = $e1 + $e3

    $e3 = $e3 / $z3
    $z3 = $z3 / $z3

    $z3 = $z3 * (-1) * $z2
    $e3 = $e3 * (-1) * $z2

    $y2 = $y2 + $y3
    $z2 = $z2 + $z3
    $e2 = $e2 + $e3

    $e3 = $e3 / $z3
    $z3 = $z3 / $z3
    GUICtrlSetData($ErgebnissX, $e1)
    GUICtrlSetData($ErgebnissY, $e2)
    GUICtrlSetData($ErgebnissZ, $e3)

    Case $Hilfe

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 615, 438, 201, 123)
    $Label1 = GUICtrlCreateLabel("Label1", 72, 80, 36, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    EndSwitch
    WEnd


    EndSwitch
    WEnd


    [autoit]
    [spoiler]

    ichh offe es ist verständlich.ich will also eine variable benutzen die sich ständigt änder.sie ändert sich wenn man auf einen button drückt.aber wenn man auf einen andern button drückt soll die variable jeweils nach den verschiedenen rechenoperationen angezeigt werden
    mfg patii

  • ich habe 2 buttons
    wenn ich auf einen drücke rechnet der etwas aus.
    wenn ich auf den 2ten button drücke soll er mir die zwischenergebnisse liefern.
    das muss ich aber nach jeder rechnung machen weil sich meine variablen ändern.
    wie kann ich das machen?
    gruß patiii

    • Offizieller Beitrag

    ich habe z.b. 1 + 1 = $a


    Das geht schon mal gar nicht ;) - wenn dann so: $a = 1 +1
    Ausgeben kannst du doch per MsgBox - oder um es anschaulicher zu machen und Klickerei zu sparen, in ein Edit ausgeben. Rechenschritt ins Edit schreiben, nächste Zeile das Ergebnis, kurzes Sleep() und nächster Schritt usw.

    Edit:
    Hier mal ein Muster

    [autoit]

    #include <GuiEdit.au3>
    Local $a = 10, $b = 20

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

    GUICreate('Test')
    $hEdit = GUICtrlCreateEdit('', 10, 10, 200, 200)
    GUISetState()

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

    Sleep(500)
    _Operate($a, $b, '+')
    Sleep(500)
    _Operate($a, $b, '-')
    Sleep(500)
    _Operate($a, $b, '*')
    Sleep(500)
    _Operate($a, $b, '/')

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

    Do
    Until GUIGetMsg() = -3

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

    Func _Operate($a, $b, $action)
    _GUICtrlEdit_AppendText($hEdit, $a & ' ' & $action & ' ' & $b & @CRLF)
    _GUICtrlEdit_AppendText($hEdit, @TAB & '=' & Execute($a & $action & $b) & @CRLF)
    EndFunc

    [/autoit]
  • hm ja danke erstmal für die hilfe
    wir kommen der sache schon näher denke ich.
    das problem ist ja, dass ich das mit einem button verknüpfen will.
    also erst wenn man auf den button drückt soll man die zwischenschritte sehen
    ist das möglich?
    also nich direkt nach dem rechenschritt eine neue code zeile sondern dann halt unter $case hilfe

  • ja möglich wäre das schon.
    aber wenn ich das erst unter dem 2ten button mache hat der ja schon alles durchgerechnet und die variable hat sich schon längst geändert...
    bevor das script überhaupt zu dem 2ten button kommt hat der die variablen schon 10 mal oder so geändert ich muss ja nach jedem schritt eine ausgabe der variable machen,d.h. es müsste eigentlich noch im oberen teil des scriptes sein denke ich
    aber eigentlich will ich dass man erst auf den button drückt...
    wenn es nicht verständlich ist bitte sagen dann versuche ich es nochmal ganz ausfürhlich

  • Ich fasse mal zusammen, was du erreichen willst:
    - Eingabe von Werten für eine Gleichung
    - Schrittweise Ausführung mit Zwischenergebnissen, jeweils warten auf Nutzerbestätigung

    Das könntest du z.B. so lösen:

    Spoiler anzeigen
    [autoit]


    Func OnButtonNextClick()
    $iStep += 1
    _Calc($iStep)
    EndFunc

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

    Func _Calc($iStep)
    ; alle Variablen global (nicht schön, aber egal)
    Switch $iStep
    Case 0
    ...
    Case 1
    ...
    Case 2
    ...
    Case ...
    EndSwitch
    EndFunc

    [/autoit]
  • ja da hast du recht
    das erste hab ich ja schon
    und der 2te teil von 2ten wird nicht verlangt
    er soll nur einma drauf drücken und dann soll alles erscheinen
    deinen quelltext kann ich nicht ganz nachvollziehen wie ich den anwenden kann.

    das problem hast du aber schon richtig erkannt
    ich wüsste wie ich das machen kann nur das wäre total viel arbeit
    theoretisch ginge es ja,dass ich nach jeder rechnung dann $a = $a1 oder so etwas mache damit ich den wert von $a an dem zeitpunkt habe.
    danach wird ja mit $a weiter gerechnet und der wert ist dann auch anders
    wenn dann $a sich verändert hat könntem an mahcen
    $a = $a2
    das hat dann ja einen anderen wert als $a1
    und dann könnte ich die am ende unter dem 2ten case benutzen
    aber das wäre etwas sehr viel arbeit ich bin mir sicher das geht einfacher oder?
    patiii