MATLAB: Browse button in GUI in Matlab

matlab gui+p

Dear All,
I am newby in Matlab GUI and I am designing a GUI with matlab which gets some directory from "browse pushbutton" , shows the directory in the "answer Edit text box" and after clicking "Load pushbutton", it should sende the value in the text box to main .m file. Also it should wait until the user browse at least something. what I did is in push buttond call back :
[FileName,FilePath]=uigetfile();
ExPath = [FilePath FileName];
set(handles.answer_edit,'String',ExPath);
guidata(hObject, handles);
So I am able to see the directory in "answer edit textbox". But My problem is in Load pushbutton. How I have to pass the results to another .mfile.
Also how I can control that the program should wait until user browse at least something in Edit textbox.
Any help is highly apprecietd.

Best Answer

You need to delete the handle of the GUI to cause the output function to run and send control back to the calling program. Perhaps this codce will help. I have a button, called btnOK, and a GUI called figMoveMask. When I click OK this code executes and then calls the outputfcn and then returns to the main calling routine with output arguments in varargout, like you did.
%--------------------------------------------------------------------
% --- Executes on button press in btnOK.
% MoveMask exits and control returns to the calling program.
function btnOK_Callback(hObject, eventdata, handles)
% hObject handle to btnOK (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global maskVerticesXCoords;
global maskVerticesYCoords;
% Put the temp variables into our master global variable.
[newX, newY] = CalculateNewCoordinates(handles);
maskVerticesXCoords = newX;
maskVerticesYCoords = newY;
uiresume(handles.figMoveMask);
delete(handles.figMoveMask);
return; % to calling program.