[Scilab-users] Stepping through a script with graphics

Jens Simon Strom j.s.strom at hslmg.de
Wed Nov 30 10:44:03 CET 2016


Hi,
I would like to share a function with the community which supports 
stepping through a script:

function!XCLICK()//Stops a script and offers restart options by pressing a key
     //Helpful for presenting a sequence of graphics or print results step-by-step
     //Call: !XCLICK(), always without arguments
     //First figure must be clicked on focus.
     //key SPACE   returns to the calling function (for next plot or script section)
     //key a       aborts execution
     //key b       sets the global variable GLOB=%t (default: %f).
     //              This can e.g. be used to break a while loop.
     //              In this case GLOB must be paired in the calling script and
     //>>if GLOB, break,end<<  has to follow>>!XCLICK()<<.
     //              Without loop key b is equivalent to key SPACE. A figure is created automatically.
     //key i       prints key options
     //Rotate and Zoom options of graphics are maintained.
     global GLOB
     GLOB=%f
     [ib,x,y]= xclick()
     if ib==32 then//SPACE, returns to calling function
       return
     elseif ib==97//a, ends execution
       disp('Script aborted.')
       xdel();
       abort
     elseif ib==105//i, shows key options
     disp(['KEY OPTIONS';
           'space: return to calling function';
           'b: set GLOB=%t';
           'a: terminate execution';
           'i: show key options'])
           !XCLICK()
     elseif ib==98//b
       GLOB=%t
       return
     else
       !XCLICK()
     end
  endfunction//!XCLICK()

//Here is how I tested the function:

xdel();
global GLOB
n=5;
for i=1:n;
   plot([1 2*i])
   !XCLICK(), if GLOB, break, end
end
surf()
!XCLICK()
clf();
plot3d()
!XCLICK()
clf();
histplot();
!XCLICK()
xdel()
while %t
   disp('Terminate infinite loop by pressing b.')
  !XCLICK(), if GLOB ,break, end
end

If the benefits of the function are easier to get please advise; flaws 
also please.
Cheers
Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161130/0317b466/attachment.htm>


More information about the users mailing list