diff general/algo/optpause.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children 03694e5c8365
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/general/algo/optpause.m	Sat Jan 12 19:21:22 2013 +0000
@@ -0,0 +1,14 @@
+function optpause(opt)
+% optpause - Optionally pause and/or update graphics
+%
+% optpause :: struct {
+%    pause :: natural/0 ~'0-nopause, 1-pause, N-timed pause in ms';
+%    drawnow :: bool/0  ~'flush graphics before pausing'
+% } => void.
+
+ps=getparam(opt,'pause',0);
+dn=getparam(opt,'drawnow',1);
+if ps, 
+	if ps>=10, pause(ps/1000); else pause; end 
+elseif dn, drawnow;
+end