Path: news.mathworks.com!not-for-mail
From: "Sven" <sven.holcombe@gmail.deleteme.com>
Newsgroups: comp.soft-sys.matlab
Subject: repetitive counter (GUI)
Date: Mon, 13 Jul 2009 20:53:01 +0000 (UTC)
Organization: University of Michigan
Lines: 34
Message-ID: <h3g6rd$58f$1@fred.mathworks.com>
References: <h3g5v9$6ep$1@fred.mathworks.com>
Reply-To: "Sven" <sven.holcombe@gmail.deleteme.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1247518381 5391 172.30.248.38 (13 Jul 2009 20:53:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 13 Jul 2009 20:53:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1326470
Xref: news.mathworks.com comp.soft-sys.matlab:555146


Follow through your code:

If counter is 2 or lower, THEN increment "counter".
OTHERWISE (ie, if counter is 3 or higher), set enable to off.

Does your program work as you intend it if you increment counter before checking if it's 2 or lower?


"ching l" <chinglnc@hotmail.com> wrote in message <h3g5v9$6ep$1@fred.mathworks.com>...
> handles = guidata(gcbo); 
> 
> if(handles.count <= 2) 
> 
> handles.count= handles.count+1;
> handles.count
> 
> 
> else
>     
>     set(hObject, 'enable', 'off') % switch off button when the limit reach
> 
> 
> end
> 
> Hi there
> 
> I would like the unable/off the push button when the counter reach 2, however, 
> the counter goes from counter= 1, counter = 2, counter = 3, counter= 3
> 
> What is the reason counter =3 is repeated twice? Is there a way to avoid the last counter to repeat twice? 
> 
> Any advice would be much appreciated.
> 
> Thanks.