GenericUI - ESC handling

Discussion of the xtools toolkit.

GenericUI - ESC handling

Postby 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 all
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
  }


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
undavide
 
Posts: 37
Joined: Thu May 07, 2009 7:09 am

Re: GenericUI - ESC handling

Postby 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?
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com
xbytor
Site Admin
 
Posts: 1986
Joined: Thu May 19, 2005 12:11 pm
Location: In Limbo

Re: GenericUI - ESC handling

Postby undavide » Wed Jun 23, 2010 3:20 pm

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

Davide
undavide
 
Posts: 37
Joined: Thu May 07, 2009 7:09 am

Re: GenericUI - ESC handling

Postby 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[i];
    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');
  }
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com
xbytor
Site Admin
 
Posts: 1986
Joined: Thu May 19, 2005 12:11 pm
Location: In Limbo


Return to xtools

Who is online

Users browsing this forum: No registered users and 1 guest

cron