The following is not a big deal but I am somewhat puzzled. Using the code below, the feedback text I get back on the GUI (or to be precise, just the Variable content), appears just when I submit the button twice. This remembers the famous title of the movie! The puzzle is underlined by the fact that a message (that I added) gives the feedback text correctly the first time after submission, not the second one.
=== Functionality of the code ====
This code is an excerpt of a bigger script. It opens a window (here it is simplified) accepting an input number. Then there is a check against a Master number (in fact I have other code that checks occurrences against other text strings). I would like that when there is no coincidence between Number inserted and Master number, in the same AHK GUI appears in a text field the Master number. This script does so, but not at the first submission, just at the second.
===Question: ====
Why? And how can it be avoided the need of the double submission?
Thank you.
Code: Select all
Gui, Add, Text, x30 y5 w170 h20 , Num_1. Occurences:
Gui, Add, Text, x2 y25 w25 h20 , Art.1
Gui, Add, Edit, x32 y25 w150 h20 vNum_1, Insert_N
MyLabelRewrite:
MsgBox, The Master num %Var_MasterN% ; for checking - when the script uses the goto, the msg shows the Master Number not so the GUI
Gui, Add, Text, x185 y5 w300 h20 , n_ %Var_MasterN%. ; appears just if Num e MasterNum are different. Now the Master variable number appears only the second submission - I cannot understand why
Gui, Add, Button, x340 y25 w30 h70 gsubmitBtn, OK
Gui, Show, x131 y91 h100 w380, New GUI Window
Sleep, 500
Return
submitBtn:
Gui, Submit, NoHide
Var_Num := Num_1
Var_MasterN = 1
If (Var_MasterN == Var_Num)
{
Msgbox, Ok the two numbers are the same
Gui, Destroy
}
Else
{
Goto MyLabelRewrite
}
ExitApp