func init // checks installation Adobe Photoshop and adds references include("AdobePhotoshop") // initialize properties if(isdef("onError")) this.setfield('ex', 'ex' + this.id) end end func doScript(data) linked("onError") ? blk.println('try {').inc() : '' if(linked("onComplete")) event("onComplete", this.make_script(data)) else blk.println(this.make_script(data), ';') end if(linked("onError")) blk.dec().println('} catch(Exception ', this.ex, ') {').inc() event("onError", this.ex + '.Message') blk.dec().println('}') end end func doScriptFile(data) linked("onError") ? blk.println('try {').inc() : '' if(linked("onComplete")) event("onComplete", this.make_script_file(data)) else blk.println(this.make_script_file(data), ';') end if(linked("onError")) blk.dec().println('} catch(Exception ', this.ex, ') {').inc() event("onError", this.ex + '.Message') blk.dec().println('}') end end func make_script(data) return( d("Photoshop", 20) + '.DoJavaScript(' + d("Script") + ', ' + sys.get_typed_field('Type.Missing', 'Arguments', 13, 2) + ', ' + sys.get_typed_field('Type.Missing', 'ExecutionMode', 14, 'ps.PsJavaScriptExecutionMode') + ')') end func make_script_file(data) return( d("Photoshop", 20) + '.DoJavaScriptFile(' + d("Path") + ', ' + sys.get_typed_field('Type.Missing', 'Arguments', 13, 2) + ', ' + sys.get_typed_field('Type.Missing', 'ExecutionMode', 14, 'ps.PsJavaScriptExecutionMode') + ')') end