function tm=iterate_sched(nextfn,X,T,varargin)
% iterate_sched - Iterate function under control of timer
%
% iterate_sched :: 
%    (A->action A)   ~'state transformer action',
%    A               ~'initial state',
%    real            ~'time between updates in seconds'
%    options {
%       drawnow   :: {0,1} /0 ~'call drawnow after each iteration';
%       busy_mode :: {'queue','drop'} /'queue'  ~'See TIMER';
%       its       :: natural / inf ~'iteration limit'
% -> timer.

	opts=prefs('its',inf,'drawnow',0,'busy_mode','queue','props',{},varargin{:});
	if opts.drawnow, post=@drawnow; else post=@nop; end

	tm=rlsched(@action,nows,T,opts.its,iterdata(nextfn,X));
	function t1=action(S,t0,t1)
		disp(S)
		post();
	end
end

