Path: news.mathworks.com!not-for-mail
From: "Bill " <millerwd@notes.udayton.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Nested Function Error?
Date: Fri, 17 Jul 2009 01:42:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <h3okt9$bng$1@fred.mathworks.com>
Reply-To: "Bill " <millerwd@notes.udayton.edu>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1247794921 12016 172.30.248.35 (17 Jul 2009 01:42:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 17 Jul 2009 01:42:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1305913
Xref: news.mathworks.com comp.soft-sys.matlab:556136


Currently, I am trying to design a GUI that has a running clock. I assumed that the best way to do it is the make a master function, "Garbage," start an infinite while loop, and embed all of the callbacks for my GUI in the infinite loop. For some reason, MATLAB doesn't like while statements that stretch across the entire program, because it says that it is an invald use of the function keyword. Any and all help would be greatly appreciated.


*********************************************************************
handles.ticFlag = 1
handles.startFlag = 1
function garbage(hObject, eventdata, handles)

while handles.ticFlag == 1

    handles.difference = toc - handles.startTime
    if handles.startFlag == 1;
        handles.timerDifference = floor(handles.difference);
        if handles.timerDifference < 10
            handles.displayedTime = horzcat('00:00:0', num2str(handles.timerDifference));
        elseif handles.TimerDifference < 60
            handles.displayedTime = horzcat('00:00:', num2str(handles.timerDifference));
        end
        set(handles.Timer, 'string', handles.displayedTime);
    end

    % --- Executes on key press with focus on figure1 and no controls selected.
    function figure1_KeyPressFcn(hObject, eventdata, handles)
    % hObject    handle to figure1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    end %end figure1_KeyPress

    end %end while statement

end %end function Garbage
*********************************************************************