Path: news.mathworks.com!not-for-mail
From: "Shanmugam Kannappan" <shanmugambe@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Nested Function Error?
Date: Fri, 17 Jul 2009 05:07:01 +0000 (UTC)
Organization: Tata Elxsi
Lines: 40
Message-ID: <h3p0tl$40m$1@fred.mathworks.com>
References: <h3okt9$bng$1@fred.mathworks.com>
Reply-To: "Shanmugam Kannappan" <shanmugambe@gmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1247807221 4118 172.30.248.37 (17 Jul 2009 05:07:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 17 Jul 2009 05:07:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1441885
Xref: news.mathworks.com comp.soft-sys.matlab:556153


"Bill " <millerwd@notes.udayton.edu> wrote in message <h3okt9$bng$1@fred.mathworks.com>...
> 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
> *********************************************************************
Hi,
why do you need "figure1_KeyPressFcn" inside while loop.
try to have this function declaretion & statements after while loop but call this function inside while loop.
& any function should start with the function name followed by arguments & statements .So remove the top two lines & put it after function garbage()
& Retry....
all the best....
Shan.....