安装了多个InDesign之后,ScriptEditor试图对脚本应该运行哪个版本很聪明。但是,我希望把我的脚本干涸,这样我只需要在整个脚本中更改一次应用程序名称。
有一个类似的问题( Applescript path to application using variable ),但这并不适用于所有的问题。问题是,为什么这不适用于所有的事情?
预期的工作如下:
tell application "Adobe InDesign CS5.5"
log name --"Adobe InDesign CS5.5.app"
log full name --"Mactastic:Applications:Adobe InDesign CS5.5:Adobe InDesign CS5.5.app:"
end一个小小的DRYing动作:
set v to "Adobe InDesign CS5.5"
set a to application v
log name of a --"Adobe InDesign CS5.5"
log full name of a
--SYNTAX ERROR: Expected end of line, etc. but found property
--"name" is highlighted in the ScriptEditor下面是另一个按预期工作的示例:
set f to (choose file)
tell application "Adobe InDesign CS5.5"
open f without showing window
end tell但是,这不能像以前那样编译:
set f to (choose file)
set v to "Adobe InDesign CS5.5"
set a to application v
tell a
open f without showing window
end
--SYNTAX ERROR: Expected “given”, “with”, “without”, other parameter name, etc. but found class name.
--"window" is highlighted in the ScriptEditor我的环境:
10.6.8
编辑:游戏结束时,我希望将一些InDesign功能抽象到我自己的类中,如下所示:
InDesign.scpt -抽象InDesign功能的类
on new()
copy me to self
--do some initializing
return self
end new
on _version()
return "Adobe InDesign CS5.5"
end _version
on _application()
return application _version()
end _application
on _open(path)
tell _application() to open path without showing window
end _openmy_script.scpt --使用上面抽象的InDesign.scpt
set InDesign to (load script file ("my:path:to:scripts:" & "Indesign.scpt"))'s new()
InDesign's _open("my:path:to:indd:file.indd")在AppleScript中,这是一个很好的机会,而ObjectiveC正是我应该考虑做这种事情的地方。但是,某些事情似乎确实起作用,比如“告诉_application()打开路径”,而“告诉_application()打开路径而不显示窗口”。
发布于 2012-02-15 20:43:25
不如:
set theApplication to "Adobe InDesign CS5.5"
using terms from application "Adobe InDesign CS5.5"
tell application theApplication
--do your thing here
end tell
end using terms from使用术语from用于让脚本编译,否则tell应用程序theApplication块中的任何内容都不会编译,这是indesign特有的。当应用程序(当应用程序是when服务或远程机器)不存在或在编译时无法访问时,使用术语是很常见的。
https://stackoverflow.com/questions/9300891
复制相似问题