function varargout = MyFirstGUI3(varargin)
% MYFIRSTGUI3 M-file for MyFirstGUI3.fig
%
% This is an "improved" version of Chapman's My First GUI example. It 
% uses an user defined property (also known as appdata) to store the
% state.
%
% Created by Dr. C. S. Tritt
% Last modified 1/16/07
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help MyFirstGUI3

% Last Modified by GUIDE v2.5 12-Jan-2007 08:44:27

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @MyFirstGUI3_OpeningFcn, ...
                   'gui_OutputFcn',  @MyFirstGUI3_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before MyFirstGUI3 is made visible.
function MyFirstGUI3_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 MyFirstGUI3 (see VARARGIN)

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

% Added code: Store count as application data in handles structure.
handles.count = 0;

% Update handles structure. Always remember to do this!
guidata(hObject, handles);

% UIWAIT makes MyFirstGUI3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = MyFirstGUI3_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in MyFirstButton.
function MyFirstButton_Callback(hObject, eventdata, handles)
% hObject    handle to MyFirstButton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%Added code. % Update count.
handles.count = handles.count + 1;

%Create and update string.
outText = sprintf('Total count: %d', handles.count);
set(handles.MyFirstText, 'String', outText);

% Update handles structure
guidata(hObject, handles);


