GenericUI - ESC handling

Discussion of the xtools Toolkit

Moderators:xbytor, DavideBarranca, Paul MR

Post Reply
undavide
GenericUI - ESC handling

Post by undavide » Tue Jun 22, 2010 8:57 am

Hi,
I've setup a project based on GenericUI batch window: my process function contains a error handling section like that:

Code: Select allcatch(e)
  {
   if (e.number == 8007) {
      alert ("The script has been halted! You will now get back to your original, untouched image.")
  // duplicate document is closed without saving, etc
  }

The problem is that, within the batch, a single ESC key press actually stops the elaboration of one image, but the batch still goes on, opening the following file.
How could I link the error handling of my process function to the error handling of the batch? So that the batch comes up with its own alert and then quit.
Thanks in advance,

Davide

xbytor

GenericUI - ESC handling

Post by xbytor » Wed Jun 23, 2010 2:40 pm

GenericUI doesn't have direct batch support.

How are you actually doing the batch? Via the JS DOM or using File > Automate > Batch?

undavide

GenericUI - ESC handling

Post by undavide » Wed Jun 23, 2010 3:20 pm

Sorry X,
I should have written: based on the SampleUI (which makes use of GenericUI).

Davide

xbytor

GenericUI - ESC handling

Post by xbytor » Wed Jun 23, 2010 3:45 pm

For the batch loop, something like this is what you might want to do.

Note that I haven't tested this :)

Code: Select all  var errors = [];

  for (var i = 0; i < files.length; i++) {  // for each file
    var file = files;
    try {

      var doc = app.open(file);
      // process the document

    } catch (e) {
       if (e.number == 8007) {
        alert ("The script has been halted! You will now get back to your original, untouched image.");

        // duplicate document is closed without saving, etc
        } else {
          var msg = "Error: " + doc.name + ' :: ' + Stdlib.exceptionMessage(e);
          errors.push(msg);
        }

        doc.close(SaveOptions.DONOTSAVECHANGES);
     }
  }

  if (errors.length > 0) {
    alert(errors.length + " errors occurred: " + errors.join('\n');
  }

Post Reply