Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI button in InDesign to cancel running script #355

Open
ffd8 opened this issue Mar 23, 2020 · 1 comment
Open

UI button in InDesign to cancel running script #355

ffd8 opened this issue Mar 23, 2020 · 1 comment

Comments

@ffd8
Copy link
Member

ffd8 commented Mar 23, 2020

This is a feature request/idea – since we are moving away from ESTK to just Sublime, there's often a problem of accidently running a script that could go on for ever.. changing a for loop from 10 to 100 and waaaaiting. With ESTK there was the great 🛑 button, but with Sublime - not sure of how to cancel a running script besides force quiting InDesign. Unless there's an obvious key to press:

what about a UI box that floats on top of InDesign with minimal basil.js info + 🛑 button, that could somehow call an exit() or equivalent code? Tried researching indesign scripting stop/abort/cancel script – but most results point to ESTK button.. curious what official VSCode answer is (if it has one). The UI popup would appear and dissapear upon load/finish automatically.

@ffd8
Copy link
Member Author

ffd8 commented Feb 20, 2021

Tested aborting a script – ie. accidental infinite loops or characters on a HUGE text.. or anything else that could accidently take too long. Found the following code to abort:
while (ScriptUI.environment.keyboardState.keyName == "Escape"){exit()}

Unfortunately, when simply placed once in the script, it doesn't work for loops. However if placed within a loop, makes it possible to abort at any time before it's finished:

  for(var i=0; i < 150; i++){
  	while (ScriptUI.environment.keyboardState.keyName == "Escape"){exit()}
  	fill(random(255));
  	rect(random(width), random(height), random(1, 50), random(1, 50));
  }

Guessing there's no preparser for JS within InDesign to try and inject such a line on all loops?
Maybe it's worth making a basic alias for that line, something like safety() or breaker() or ______?
And encourage students to include that if concerned about being able to abort a script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant