Skip to main content
Known Participant
February 5, 2018
Question

Error Checking of Dialog Windows Input

  • February 5, 2018
  • 1 reply
  • 406 views

I have three functions:

createDialog() - creates a dialog window for input

errors() - check for errors in the dialog window

results() - generate the results of the dialog window

All three functions work as expected. For example, after the dialog is created if there are no errors the results generate an InDesign file. If there is an error, an alert is created and everything stops.

I am trying to createDialog() after errors() and do so until there are no errors and results() are returned without having to run the script from the Scripts Panel. The best I could do is createDiallog() after an error check by

if (typeof createDiallog !== 'undefined' || createDiallog !== null){

    errors();

    createDialog();

}

but this will not re-run errors() after clicking OK.

Is it possible to do what I am trying to accomplish?

This topic has been closed for replies.

1 reply

Silly-V
Legend
February 5, 2018

The best way is to not close your original createDialog dialog, but to inform the user of the errors and have them try again with valid input or cancel the dialog to abort the operation.

You can have your "Ok" button perform a validation of input elements, and only perform a window.close() when your results are acceptable.

At the bottom of the window you can have the typical if (w.show() == 2) { return false (or null) } else { return resultObj } statement. If the dialog was canceled, it will return a 2. But if your custom w.close() function closed the window, it's not going to be a 2, taking your code through the else block.

joevAuthor
Known Participant
February 5, 2018

Sorry, I forgot to say I am using native InDesign dialog window.

It seems that when I do alert(createDialog) right after createDialog.show() it always says false and only shows the alert once. When I click OK or Cancel the window closes. By assigning createDialog.show() to a variable, I then receive a true for OK and false for cancel.

Silly-V
Legend
February 5, 2018

So ID scripting has yet another ScriptUI built-in? Wonder what advantages there are.