I need an help to understand a variable declared outside the func and "recreated" inside the func.
This is an example:
AutoIt
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $MYVAR ; I'll declare an empty var _MyTest() Func _MyTest() $Form1 = GUICreate("Form1", 196, 106, 204, 136) $Input = GUICtrlCreateInput("Input1", 32, 24, 121, 21) $Button = GUICtrlCreateButton("Button1", 56, 56, 75, 25) GUISetState(@SW_SHOW) $MYVAR = GUICtrlRead($Input) ; now $MYVAR read from input 1 ; P.S I have 15 of this While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button MsgBox(0,"WRONG",$MYVAR) ; --> This return always the first value MsgBox(0,"CORRECT", GUICtrlRead($Input)) ; This retur the correct value EndSwitch WEnd EndFunc
How i can "recreate" the variable inside the $Button without rewrite the same line? I don't want to do this way:
Case $Button1 $MYVAR1 = GUICtrlRead($Input1) $MYVAR2 = GUICtrlRead($Input2) ;etc: MsgBox(0,"CORRECT",$MYVAR1) Case $Button2 $MYVAR1 = GUICtrlRead($Input1) $MYVAR2 = GUICtrlRead($Input2) ;etc: MsgBox(0,"CORRECT",$MYVAR1)
But something in one time only like before, or a "correct" method to store this variable, maybe is wrong what i do.
Thanks