From: Daniel on 10 Jun 2010 06:55 The waitfor function can be used to wait until a particular property of a graphics object takes on a specific value. I am looking for a similar function that would wait until a particular property of an object of a user defined custom class takes on a specific value. Bascially, I am looking for an extended version of waitfor that works with objects of any class. Does this exist? In most cases I am waiting for a logical property of the object to change from false to true. I could imagine making a toggle button uicontrol, that I keep hidden, and having the set method of my object update the state of the toggle button, and then using waitfor with the toggle button. This seems contrived to me. I am wondering if there is maybe a better way by setting the SetObservable property to true and building a waitfor function around that. Or maybe even a method this does not require all the properties of the class to be setobservable.
From: Steven Lord on 10 Jun 2010 12:10 "Daniel " <daniel_shub(a)yahoo.com> wrote in message news:huqgar$qv5$1(a)fred.mathworks.com... > The waitfor function can be used to wait until a particular property of a > graphics object takes on a specific value. I am looking for a similar > function that would wait until a particular property of an object of a > user defined custom class takes on a specific value. > Bascially, I am looking for an extended version of waitfor that works with > objects of any class. Does this exist? > > In most cases I am waiting for a logical property of the object to change > from false to true. I could imagine making a toggle button uicontrol, that > I keep hidden, and having the set method of my object update the state of > the toggle button, and then using waitfor with the toggle button. > > This seems contrived to me. I am wondering if there is maybe a better way > by setting the SetObservable property to true and building a waitfor > function around that. Or maybe even a method this does not require all the > properties of the class to be setobservable. So you basically want an overload of the two-input (and potentially the three-input) syntax version of WAITFOR for your object? The most basic version, sans error checking, is: function waitfor(myobject, propertyname, propertyvalue) if nargin < 3 propertyvalue = myobject.(propertyname); end while isequal(myobject.(propertyname), propertyvalue) drawnow; end Add error checking (for propertyname not being a property of myobject, for the object being deleted, for the attempt to access the property value erroring for some reason, etc.) to taste. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Daniel on 10 Jun 2010 16:36 "Steven Lord" <slord(a)mathworks.com> wrote in message <hur2pf$nig$1(a)fred.mathworks.com>... > So you basically want an overload of the two-input (and potentially the > three-input) syntax version of WAITFOR for your object? The most basic > version, sans error checking, is: > > function waitfor(myobject, propertyname, propertyvalue) > if nargin < 3 > propertyvalue = myobject.(propertyname); > end > while isequal(myobject.(propertyname), propertyvalue) > drawnow; > end I do not think this will work for nested calls to this overloaded waitfor. If a function calls waitfor and while the waitfor loop is running a callback happens that calls another waitfor, the second waitfor will effectively halts the first waitfor loop. Therefore, if before the second waitfor is statisfied another callback occurs that statisfies the first waitfor nothing will happen.
|
Pages: 1 Prev: image read error Next: Replace Negative values with Non-zero values |