<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi,<br>
I would like to share a function with the community which supports
stepping through a script:<br>
<br>
<pre style="font-family:Monospaced;font-style:normal;font-size:12.0;">function <span style="text-decoration: underline;">!XCLICK</span>()<span style="font-style: italic;">//Stops a script and offers restart options by pressing a key</span>
<span style="font-style: italic;">//Helpful for presenting a sequence of graphics or print results step-by-step </span>
<span style="font-style: italic;">//Call: !XCLICK(), always without arguments</span>
<span style="font-style: italic;">//First figure must be clicked on focus.</span>
<span style="font-style: italic;">//key SPACE returns to the calling function (for next plot or script section)</span>
<span style="font-style: italic;">//key a aborts execution </span>
<span style="font-style: italic;">//key b sets the global variable GLOB=%t (default: %f).</span>
<span style="font-style: italic;">// This can e.g. be used to break a while loop.</span>
<span style="font-style: italic;">// In this case GLOB must be paired in the calling script and</span>
<span style="font-style: italic;">// </span><span style="font-style: italic;">></span><span style="font-style: italic;">></span><span style="font-style: italic;">if GLOB, break,end</span><span style="font-style: italic;"><</span><span style="font-style: italic;"><</span><span style="font-style: italic;"> has to follow </span><span style="font-style: italic;">></span><span style="font-style: italic;">></span><span style="font-style: italic;">!XCLICK()</span><span style="font-style: italic;"><</span><span style="font-style: italic;"><</span><span style="font-style: italic;">.</span>
<span style="font-style: italic;">// Without loop key b is equivalent to key SPACE. A figure is created automatically.</span>
<span style="font-style: italic;">//key i prints key options</span>
<span style="font-style: italic;">//Rotate and Zoom options of graphics are maintained. </span>
global GLOB
GLOB=%f
[ib,x,y]= xclick()
if ib==32 then<span style="font-style: italic;">//SPACE, returns to calling function</span>
return
elseif ib==97<span style="font-style: italic;">//a, ends execution</span>
disp('Script aborted.')
xdel();
abort
elseif ib==105<span style="font-style: italic;">//i, shows key options</span>
disp(['KEY OPTIONS';
'space: return to calling function';
'b: set GLOB=%t';
'a: terminate execution';
'i: show key options'])
<span style="text-decoration: underline;">!XCLICK</span>()
elseif ib==98<span style="font-style: italic;">//b </span>
GLOB=%t
return
else
<span style="text-decoration: underline;">!XCLICK</span>()
end
endfunction<span style="font-style: italic;">//!XCLICK()
<big><big>//Here is how I tested the function: </big></big>
</span>xdel();
global GLOB
n=5;
for i=1:n;
<span style="text-decoration: underline;">plot</span>([1 2*i])
!XCLICK(), if GLOB, break, end
end
<span style="text-decoration: underline;">surf</span>()
!XCLICK()
<span style="text-decoration: underline;">clf</span>();
plot3d()
!XCLICK()
<span style="text-decoration: underline;">clf</span>();
<span style="text-decoration: underline;">histplot</span>();
!XCLICK()
xdel()
while %t
disp('Terminate infinite loop by pressing b.')
!XCLICK(), if GLOB ,break, end
end
</pre>
If the benefits of the function are easier to get please advise;
flaws also please.<br>
Cheers<br>
Jens<br>
</body>
</html>