app.doScript和$ .evalFile之间的区别是什么? [英] What is the difference between app.doScript and $.evalFile?

查看:788
本文介绍了app.doScript和$ .evalFile之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到目前为止发现的唯一的区别是:如果由 app.doScript 运行一个脚本返回一个错误,错误的文件和行号由被覆盖在 app.doScript 通话的文件和行号。

The only difference I have found so far: If a script that is run by app.doScript returns an error, the file and line number of the error are overridden by the file and line number of the app.doScript call.

还有没有其他的区别,我应该知道的吗?

Are there any other differences I should know about?

下面的示例code,演示了上面的区别:

Here's sample code that demonstrates the above difference:

首先运行的InDesign:

First run InDesign:

c:
cd "C:\Program Files\Adobe\Adobe InDesign CS6 Server x64"
InDesignServer.com -port 12345
pause

接下来创建一个批处理文件来运行一个脚本:

Next create a batch file to run a script:

c:
cd "C:\Program Files\Adobe\Adobe InDesign CS6 Server x64"
sampleclient -host localhost:12345 -server "C:/doscript_vs_evalfile/call_doScript.jsx"
pause

这是call_doScript.jsx,这将调用app.doScript。

This is "call_doScript.jsx", which will call app.doScript.

try {
    app.doScript(new File("/c/doscript_vs_evalfile/called_by_doScript.jsx"));
    "Success";
}
catch (e) {
    var sError = "Encountered " + e.name + " #" + e.number + " at line " + e.line + " of file " + e.fileName + "\n" + e.message;
    app.consoleout(sError);
    sError;
}

这是called_by_doScript.jsx,这就是所谓的previous脚本:

This is "called_by_doScript.jsx", which is called by the previous script:

app.consoleout("Running called_by_doScript.jsx");
// Produce error
var a = b;

运行批处理文件,这是结果:

Run the batch file and this is the result:

02/25/13 13:30:03 INFO  [javascript] Executing File: C:\doscript_vs_evalfile\call_doScript.jsx
02/25/13 13:30:03 INFO  [javascript] Executing File: C:\doscript_vs_evalfile\called_by_doScript.jsx
02/25/13 13:30:03 INFO  [script] Running called_by_doScript.jsx
02/25/13 13:30:03 INFO  [script] Encountered ReferenceError #2 at line 2 of file /c/doscript_vs_evalfile/call_doScript.jsx
b is undefined

请注意,上面的错误是不正确。错误是由行3 called_by_doScript的,不排队2 call_doScript引起

Notice that the error above is incorrect. The error was caused by line 3 of called_by_doScript, not line 2 of call_doScript.

现在修改脚本,以使用$ .evalFile,我们得到这样的结果:

Now modify the scripts to use $.evalFile, and we get this result:

02/25/13 13:32:39 INFO  [javascript] Executing File: C:\doscript_vs_evalfile\call_evalFile.jsx
02/25/13 13:32:39 INFO  [script] Running called_by_evalFile.jsx
02/25/13 13:32:39 INFO  [script] Encountered ReferenceError #2 at line 3 of file /c/doscript_vs_evalfile/called_by_evalFile.jsx
b is undefined

请注意,错误报告,现在在正确的位置。

Notice that the error is now reported at the correct location.

编辑:

我发现很少的一些文档。它并没有真正回答我的问题,但它确实描述不同的可选参数。

I found sparse documentation. It doesn't really answer my question, but it does describe different optional parameters.

doScript: Adob​​e公司的InDesign CS6脚本指南:JavaScript的(<一href="http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/indesign/sdk/cs6/scripting/InDesign_ScriptingGuide_JS.pdf"相对=nofollow>直接链接
请参见第16页,使用doScript法

doScript: Adobe InDesign CS6 Scripting Guide: JavaScript (direct link)
See page 16, "Using the doScript Method"

evalFile: <一个href="http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/indesign/pdfs/JavaScriptToolsGuide_CS5.pdf"相对=nofollow> JavaScript工具指南:Adobe Creative Suite的5
请参阅第219页

evalFile: Javascript Tools Guide: Adobe Creative Suite 5
See page 219

推荐答案

$。evalFile是同时app.doScript由InDesign中实现的ExtendScript功能。

$.evalFile is an ExtendScript feature while app.doScript is implemented by InDesign.

$。evalFile确实

$.evalFile does

  • 维持$ .STACK
  • 在考虑$ .includePath
  • 在其他目标应用程序的工作

app.doScript能

app.doScript can

  • 通过参数
  • 更改语言,例如AppleScript的
  • 使用#targetengine解决其他会话
  • 修改的undo /交易模式尽可能的支持

但...

  • 在嵌套doScript调用覆盖参数
  • 在一个复杂的设置,我遇到了麻烦传递超过12参数之后进行调试。
  • 在整个doScript单步麻烦

此外,如你发现,错误处理不同。请关注例外...

Also, as you found, error handling differs. Keep an eye on exceptions ...

这篇关于app.doScript和$ .evalFile之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆