Fault Tolerant Scripts

Discussion of the xtools Toolkit

Moderators: Tom, Kukurykus

xbytor

Fault Tolerant Scripts

Post by xbytor »

I'm posting up my scripts that will help in writing Fault Tolerant JavaScript code for Photoshop.

The script is FTScript.jsx. This needs to be put in the Startup Scripts folder and Bridge and Photoshop need to be restarted so that they see the script.

FTScriptTest.jsx. is a demo script. For this to do something interesting, you need to modify it so that FTest.imageFolder is point to a folder with 25-30 images.

When you run the test script, it will 'process' 10 images (and show an alert). It will then shutdown Photoshop after sending a 'restart' message to Bridge. Bridge restarts Photoshop and sends a 'continue processing' message so that next 10 images are processed. This continues until the application script stops sending 'restart' message to Bridge.

I will be simplifying the API so that FTScriptTest.jsx will become significantly simpler. I plan on integrating this into CSX so I expect that will be the driving force towards simplification.

-X
xbytor

Fault Tolerant Scripts

Post by xbytor »

Here's an update to the fault tolerant scripts.

I added a new script into the mix specifically for handling files. The result of this work is a application script that looks like this:

Code: Select all//@show include
//@includepath "/c/Program Files/Adobe/xtools;/Developer/xtools"
//@include "xlib/FTBatch.jsx"

FTBatch.imageFolder = "~/images";

FTBatch.prototype.init = function() {
  var res = [];
  var folder = new Folder(FTBatch.imageFolder);
  var files = folder.getFiles("*.jpg");
  return files;
};

FTBatch.prototype.batchSize = 7;

FTBatch.prototype.processFile = function(file) {
  alert("File: " + file.absoluteURI);
  return true;
};

var ftest = new FTBatch();
ftest.main();


This one has the batch size set to 7 which means it will automatically stop and start Photoshop after 7 images have been processed. The 'processFile' method is where the processing functionality would be added. In this test case, it only pops up an alert with the file being processed.

-X