octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

waitbar (frac, "msg") syntax


From: John W. Eaton
Subject: waitbar (frac, "msg") syntax
Date: Sat, 5 Nov 2011 15:57:46 -0400

On  5-Nov-2011, Rik wrote:

| I see you disabled the subject line waitbar syntax in this changeset:
| 
| changeset:   13821:4d1927edf194
| user:        John W. Eaton <address@hidden>
| date:        Fri Nov 04 16:35:58 2011 -0400
| summary:     waitbar: use previous bar if nargin == 1, not nargout == 1
| 
| This does make the function fully Matlab compatible, but I thought it was a
| useful addition to be able to update the message on the current waitbar. 
| 
| For example:
| 
| h = waitbar (0, "Initializing data");
| waitbar (0.1);
| waitbar (0.2);
| waitbar (0.3, "Starting phase 1");
| waitbar (0.4);
| waitbar (0.5);
| waitbar (0.6, "Starting phase 2");
| ....
| waitbar (1.0, "Calculation complete")
| 
| You can achieve the  functionality above by always passing in a waitbar
| handle and that's what Matlab users have to do.  At any rate, if the
| function stays this way then the @deftypefnx which describes "waitbar
| (frac, "msg")" should be deleted since it isn't an option.

I think we should go with compatibility here because in Matlab, you
can do

  h = waitbar (frac);

to get the handle of the current waitbar.  Before the change I made,
that would create a new waitbar.  I think we might see bug reports
about that.

Also in Matlab, won't

  h = waitbar (0, 'foo');
  waitbar (0.1, 'bar');

create two waitbars?  We would be incompatible there too.

And, should the following work?

  waitbar (0.1, '1');
  h = waitbar (0.2, '2');
  close (h);
  waitbar (0.3);  ## error, create new, or modify the first waitbar?

If the last statement modifies the first waitbar, then we need to do
something more sophisticated to keep track of the current waitbar.  We
are currently just keeping track of the last one that was used.
Instead, I think we would have to do something like keep track of a
stack of waitbar handles and register a function to run when a waitbar
handle is closed so that deleted waitbars could be removed from the
stack (or is it possible .  That seems like a lot of effort though, so
I don't really want to do it.  WDMD?  Or, maybe it is possible to just
look back through the list of root figure children and write to the
most recently created waitbar.  If that's the behavior of Matlab, then
I think it would be simpler to be compatible.  So WDMD for the following?

  h1 = waitbar (0.1, '1');
  h2 = waitbar (0.1, '2');
  waitbar (0.2, h1)
  waitbar (0.3)     ## modify most recently modified or created?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]