I made a skulpt project for my students. Every time they made an infinite loop, the browser crashes and the code is gone. That is very frustrating for the students. I saw a stop button on https://trinket.io/python, but don't understand how they made it. I followed the instructions on http://www.skulpt.org/ to integrate skulpt in my site.
Any ideas?
Not particularly well documented - there are certain options that you can add to the
Sk.configureone of which isexecLimitin ms.e.g. From the example http://skulpt.org/using.html
Skulpt will raise a
TimeLimitErrorif theexecLimitis reached.in terms of the cancel button - there's an additional setting
yieldLimitwhich you can set inms. This will essentially pause the execution at intervals. And you can add a handler to deal with this pause.Again not documented well by Skulpt but here's a JS Fiddle that is proof of concept:
https://jsfiddle.net/bjLuq5s7/