From: vito on
Hello everybody, i need your help.
I am developing a GUI with GUIDE. When I call the figure and before figure is shown, in mygui_OpeningFcn(hObject, eventdata, handles, varargin) function, i check the correct value of the parameters shown in the figure.
In case the parameter values are correct, then the execution flux continues, and the figure appears in the screen. But in other case i want to stop the execution and not to show the figure.

I show you my code:


function mygui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUI_Param_Data_Take (see VARARGIN)

% Choose default command line output for GUI_Param_Data_Take
handles.output = hObject;

% Adjust the window position to the screen
movegui(gcf,'center')

% Load the parameters in the structure
DataTakeDefinition = getappdata(0, 'DataTakeParam');

%% Set the radiobuttons value
switch lower(DataTakeDefinition.RequestType)
case 'standard'
set(handles.rb_requestStandard, 'value', 1)
set(handles.rb_requestAdvanced, 'value', 0)
case 'advanced'
set(handles.rb_requestStandard, 'value', 0)
set(handles.rb_requestAdvanced, 'value', 1)
otherwise % Parameter incorrect
response = questdlg({['The value ', DataTakeDefinition.RequestType, ...
' is not a valid value.']; ...
'Press OK to set the default value to Standard.'; ...
'Press Cancel to edit the Properties Data Take File to correct it.'}, ...
'Wrong parameter','OK','Cancel','OK');

switch response
case 'OK'
set(handles.rb_requestStandard, 'value', 1)
set(handles.rb_requestAdvanced, 'value', 0)

case 'Cancel', '' % Close the window .THIS IS THE CASE THAT I CAN'T SOLVE
delete(handles.figure1);
return

end

end

If someone can help me I would be very grateful.

Thanks a lot