[Scilab-users] Stepping through a script with graphics

Jens Simon Strom j.s.strom at hslmg.de
Wed Nov 30 22:05:52 CET 2016


Hi,
This is my preliminary debug function:

xdel()
figure('position',[200,0,50,50])
plot(0,0)//auxiliary window
y=0
for x=1:100
     y=y+1/x.^2,!XCLICK()
end

Cheers
  Jens
---------------------------------------------------------

Am 30.11.2016 21:13, schrieb Claus Futtrup:
> Hi
>
> Stepping through a script would be a wonderful (debugging) feature to 
> be added to SciNotes.
>
> 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.
>
> Best regards,
> Claus
>
> On 30-11-2016 10:44, Jens Simon Strom wrote:
>> 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
>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161130/34c8114b/attachment.htm>


More information about the users mailing list