<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi<br>
      <br>
      Stepping through a script would be a wonderful (debugging) feature
      to be added to SciNotes.<br>
      <br>
      Many years ago when I was programming Turbo Pascal 7, inserting a
      breakpoint and then stepping through a section of the code while
      monitoring variables, was a good way to study the logic and debug
      code.<br>
      <br>
      Best regards,<br>
      Claus<br>
      <br>
      On 30-11-2016 10:44, Jens Simon Strom wrote:<br>
    </div>
    <blockquote cite="mid:583E9F63.9060902@hslmg.de" type="cite">
      <meta http-equiv="content-type" content="text/html;
        charset=windows-1252">
      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>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>