3

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?

Coupido
  • 151
  • 7

1 Answers1

2

Not particularly well documented - there are certain options that you can add to the Sk.configure one of which is execLimit in ms.

e.g. From the example http://skulpt.org/using.html

Sk.configure({output:outf, read:builtinRead, execLimit: 5000}); 

Skulpt will raise a TimeLimitError if the execLimit is reached.


in terms of the cancel button - there's an additional setting yieldLimit which you can set in ms. 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/

user9476284
  • 100
  • 2
  • 7