Das ist ein kleiner und gekürzter Ausschnitt.
Es gibt 4 Eingabefelder.
2 Stück gehören immer "zusammen".
Wenn man auf den Button "Speichern" klickt, dann werden 2 Inputfelder verglichen (immer die, die nebeneinander sind)
Dabei gilt:
Der linke Input müsste immer der Kleinere sein.
Der rechte demnach der Größere.
Beide Inputs haben maximale Größen, die sie erreichen können.
- wenn sie diese Grenzen überrschreiten, dann wird ein vorgeschriebener Standardwert genommen
Sind beide Inputs gleichgroß, dann wird ihnen der Standardwert zugeschrieben
Ist der erste Wert größer als der zweite, dann sollen sie vertauscht werden.
Genau beim letzten Punkt liegt das Problem.
Bei mir vertauschen sich die Werte, auch wenn sie sich nicht vertauschen sollten!?
Wo liegt mein Denkfehler?
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#Include <GuiButton.au3>
#include <ButtonConstants.au3>
Global $min, $max, $min_d, $max_d
Global $button0, $input0, $input1, $input2, $input3
$hGUI = GUICreate("Name", 400, 300)
GUICtrlCreateGroup("Test", 30, 90, 100, 180)
$label0 = GuiCtrlCreateLabel("Zahl1", 40, 108, -1, -1)
GUICtrlSetTip($label0, "Zahlenbestimmung: Min. - Max.")
$label1 = GuiCtrlCreateLabel("Min.", 40, 123, -1, -1)
GUICtrlSetTip($label1, "Min-Wert: [38;11199[")
$label2 = GuiCtrlCreateLabel("Max.", 90, 123, -1, -1)
GUICtrlSetTip($label2, "Max-Wert: ]39;11200]")
$input0 = GUICtrlCreateInput("70", 40, 138, 38, 20)
$input1 = GUICtrlCreateInput("11200", 78, 138, 38, 20)
$input2 = GUICtrlCreateInput("50", 40, 183, 38, 20)
$input3 = GUICtrlCreateInput("60", 78, 183, 38, 20)
$button0 = GuiCtrlCreateButton("Speichern", 50, 205)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()
While(1)
$stateGUI = GUIGetMsg()
Switch $stateGUI
Case $GUI_EVENT_CLOSE
Exit
Case $button0
test()
EndSwitch
WEnd
Func test()
$min = GUICtrlRead($input0)
$max = GUICtrlRead($input1)
$min_d = GUICtrlRead($input2)
$max_d = GUICtrlRead($input3)
If $min > $max Then
$x = $max
$max = $min
$min = $x
GUICtrlSetData($input0, $min)
GUICtrlSetData($input1, $max)
EndIf
If $min < 38 Or $min > 11199 Or $min = $max Then
$min = 70
GUICtrlSetData($input0, 70)
EndIf
If $max > 11200 Or $max < 39 Or $min = $max Then
$max = 11200
GUICtrlSetData($input1, 11200)
EndIf
If $min_d > $max_d Then
$x = $max_d
$max_d = $min_d
$min_d = $x
GUICtrlSetData($input0, $min_d)
GUICtrlSetData($input1, $max_d)
EndIf
If $min_d > 59999 Or $min_d < 10 Or $min_d = $max_d Then
$min_d = 50
GUICtrlSetData($input2, 50)
EndIf
If $max_d > 60000 Or $max_d < 11 Or $min_d = $max_d Then
$max_d = 60
GUICtrlSetData($input3, 60)
EndIf
EndFunc
.. Verkürzungen müssen nicht sein (Arrays etc.). ![]()