I created a simple Gui with 4 edit boxes.
After typing in the values and pressing OK, I would like to see the highest value in a MessageBox.
I managed it to get it work.
However, I would like to know if I really have to use 4 variables and 4 if statements.
As far as I know, I can't use Value%A_Index% because there is no loop here.
And my last question would be how can I determinate the highest 2 values?
In this example I typed in 5, 2, 4, 8.
The message box correctly shows 8 as highest value.
What must I do to have 5 and 8 there?
I already tried something with Sort, but I didn't understand how it works and if it is what I need.
Code: Select all
F7::
Gui, Show, w230 h200
Gui, Add, Text, BackgroundTrans x50 y0, Type in values
Gui, Add, Text, BackgroundTrans x2 y51, Value 1
Gui, Add, Text, BackgroundTrans x2 y82, Value 2
Gui, Add, Text, BackgroundTrans x2 y113, Value 3
Gui, Add, Text, BackgroundTrans x2 y141, Value 4
Gui, Add, Edit, w50 x45 y45 vValue1 gSubmit_All
Gui, Add, Edit, w50 x45 y76 vValue2 gSubmit_All
Gui, Add, Edit, w50 x45 y107 vValue3 gSubmit_All
Gui, Add, Edit, w50 x45 y138 vValue4 gSubmit_All
Gui, Add, Button, x100 y170 gOk, OK
Gui, Add, Button, x150 y170 gCancel, Cancel
Submit_All:
Gui, Submit, NoHide
return
Ok:
Gui, Submit, NoHide
Gui, Destroy
Cancel:
Gui, Destroy
;--------------------------------------------------------------
global maxValue
global Value1
global Value2
global Value3
global Value4
HighestValue()
Sort, Value, N
MsgBox, %Value1%, %Value2%, %Value3%, %Value4%, %maxValue%
maxValue = 0
return
HighestValue()
{
if (Value1 > maxValue)
{
maxValue := Value1
}
if (Value2 > maxValue)
{
maxValue := Value2
}
if (Value3 > maxValue)
{
maxValue := Value3
}
if (Value4 > maxValue)
{
maxValue := Value4
}
}
return