I'm just trying to understand how a GUI works inside a function
& about GUI's in general. Obviously, I'm a little confused
What I would like to do is pretty simple (I thought)
- Main program calls a function that creates a GUI
- Have MAIN program wait until function finishes execution (of course)
- Have GUI function prompt user for a numeric value
- Have GUI function prompt user to select a date
- Display both values inside the GUI function
- Return the numeric value to the main program
WHAT AM I DOING WRONG?? WHY WON'T THE FOLLOWING WORK?????
Code:
;------------ Get Medical Record # ------------------------
ReturnValue = ""
MRN := GetMRN(ReturnValue)
MsgBox, Here is the return value of the function "MRN" %MRN%
ExitApp
;---------------- Function GetMRN ---------------
GetMRN(ReturnValue)
{
Static MRN
Static MyCalendar
Gui, Add, Text, ,Enter the Medical Record Number Here
Gui, Add, Button, Default, OK
Gui, Add, Edit, vMRN
Gui, Add, MonthCal, vMyCalendar
Gui, Add, Button, Default, OK
Gui, Add, Edit, MyCalendar
Gui, Show
; I've disabled the "RETURN" line below because it causes the entire function to RETURN prematurely
; return
ButtonOK:
Gui, Submit, NoHide
; Now, instead of waiting for user to click OK, the following line executes immediately
MsgBox The "ButtonOK" GUI subroutine reports that you entered "%MRN%
ReturnValue = %MRN%
GUI, Destroy
MsgBox The "ButtonOK" GUI subroutine for Calendar reports a selected date of "%MyCalendar%
return %ReturnValue%
}