In an attempt to simplify my code to try and focus on the problem I'm having I over simplified it.
I have a function called Logout_GUI(Login,OperationID,RunType,LogoutType), which contains multiple GUIs inside it.
4 variables are passed to this function, where one of the variables, LogoutType determines which GUI is called.
The GUI is then shown and asks for an additional 3 variables. I now need to pass those 3 variables along with the remaining 3 variables that were passed to the Logout_GUI function.
In essences I'm getting 3 variables outside of the GUI then requesting another 3 variables with the GUI and need to pass all 6 along to another function.
Here's the code if I use the GUI Submit
Code: Select all
Logout_GUI("1234","388191","Run","Operator")
Logout_GUI(Login,OperationID,RunType,LogoutType)
{
Global EnteredQTY
Global EnteredScrapQTY
Global EnteredOpComplete
Global Logout
If (LogoutType = "Operator")
{
Gui +hWndhMainWnd
Gui Font, s20 Bold
Gui Add, Text, x130 y46 w620 h45 +0x200 +Center, Logout of Operation
Gui Font
Gui Font, s15 Bold
Gui Add, Text, x76 y118 w283 h23 +0x200 +Center, Enter QTY Completed
Gui Font
Gui Font, s15 Bold
Gui Add, Edit, vEnteredQTY x158 y166 w120 h32 +Center
Gui Font
Gui Font, s15 Bold
Gui Add, Button, hWndhBtnConfirm gLogout x217 y320 w165 h46, LOGOUT
Gui Font
Gui Font, s15 Bold
Gui Add, Button, hWndhBtnCancel2 x479 y320 w165 h46, CANCEL
Gui Font
Gui Font, s15 Bold
Gui Add, Text, x511 y120 w283 h23 +0x200 +Center, Enter Scrap QTY
Gui Add, Edit, vEnteredScrapQTY x594 y166 w120 h32 -VScroll
Gui Font
Gui Font, s15 Bold
Gui Add, Text, x258 y242 w213 h23 +0x200 +Center, Operation Complete?
Gui Font
Gui Font, s15 Bold
Gui Add, DropDownList, vEnteredOpComplete x504 y238 w70, NO||YES
Gui Font
Gui Show, x378 y338 w880 h417, Window
Return
Logout:
GUI Submit
msgbox % EnteredQTY "`n" EnteredScrapQTY "`n" EnteredOpComplete
msgbox % Login "`n" OperationID "`n" RunType
GuiLogoutEscape:
GuiLogoutClose:
ExitApp
}
}
When using the GUI submit the 3 variables from the GUI are passed on but the 3 variables from outside the GUI (i.e Login, OperationID, RunType) return a blank.
To get around this I need to bind the function. So I changes the g-label gLogout to vlogout and get the following:
Code: Select all
Logout_GUI("1234","388191","Run","Operator")
Logout_GUI(Login,OperationID,RunType,LogoutType)
{
Global EnteredQTY
Global EnteredScrapQTY
Global EnteredOpComplete
Global Logout
If (LogoutType = "Operator")
{
Gui +hWndhMainWnd
Gui Font, s20 Bold
Gui Add, Text, x130 y46 w620 h45 +0x200 +Center, Logout of Operation
Gui Font
Gui Font, s15 Bold
Gui Add, Text, x76 y118 w283 h23 +0x200 +Center, Enter QTY Completed
Gui Font
Gui Font, s15 Bold
Gui Add, Edit, vEnteredQTY x158 y166 w120 h32 +Center
Gui Font
Gui Font, s15 Bold
Gui Add, Button, hWndhBtnConfirm vLogout x217 y320 w165 h46, LOGOUT
Gui Font
Gui Font, s15 Bold
Gui Add, Button, hWndhBtnCancel2 x479 y320 w165 h46, CANCEL
Gui Font
Gui Font, s15 Bold
Gui Add, Text, x511 y120 w283 h23 +0x200 +Center, Enter Scrap QTY
Gui Add, Edit, vEnteredScrapQTY x594 y166 w120 h32 -VScroll
Gui Font
Gui Font, s15 Bold
Gui Add, Text, x258 y242 w213 h23 +0x200 +Center, Operation Complete?
Gui Font
Gui Font, s15 Bold
Gui Add, DropDownList, vEnteredOpComplete x504 y238 w70, NO||YES
Gui Font
Gui Show, x378 y338 w880 h417, Window
Return
GuiControlGet, EnteredOpComplete
GuiControlGet, EnteredQTY
GuiControlGet, EnteredScrapQTY
BoundLogoutFunc := func("Logout_Operation").Bind(Login,OperationID,RunType,EnteredOpComplete,EnteredQTY,EnteredScrapQTY)
GuiControl, +g, Logout, %BoundLogoutFunc%
GuiLogoutEscape:
GuiLogoutClose:
ExitApp
}
}
Now the 3 variables outside the GUI are passed along but this code is executed as soon as the GUI loads not giving me time to enter the variables in the GUI.
I can't put the bound function inside a submit since those variables are lost before it reaches that point.
I tried doing what
just me suggest and placing the bound function inside a function. However I get an error saying you can't place a function inside a function.
I'm trying to wrap my brain around this. The only thing I can think of is if I bind the function when the GUI is created without the 3 variables that the GUI asks for. Then I somehow submit that bound function along with the variables from the GUI.
I'm not really sure how I would do this since the act executing the function is done by:
GuiControl, +g, Logout, %BoundLogoutFunc%
At the same time submitting the GUI is done by
Both of these involve clicking the same button. I guess I would have to use a different control to bind the function.
Is what I'm trying to do even possible?