【发布时间】:2014-11-21 04:26:53
【问题描述】:
这让我失去理智。这是我试图开始工作的代码的简短版本。它返回奇怪的值并在随机高度和宽度设置时给我错误。我一辈子都想不通我哪里错了!我认为我确定输入的逻辑门是坚如磐石的!任何帮助将不胜感激!
tell application "Adobe InDesign CS6"
activate
set myDoc to active document
set origLevel to user interaction level of script preferences
set user interaction level of script preferences to interact with all
set myDialog to make dialog with properties {name:"Make Template", can cancel:true}
tell myDialog
tell (make dialog column)
tell (make border panel)
tell (make dialog column)
make static text with properties {static label:"Width:", min width:60}
make static text with properties {static label:"Height:", min width:60}
make static text with properties {static label:"Bleed:", min width:60}
end tell
tell (make dialog column)
set myWidth to make text editboxes with properties {edit contents:"", min width:60}
set myHeight to make text editboxes with properties {edit contents:"", min width:60}
set myBleed to make text editboxes with properties {edit contents:"", min width:60}
end tell
tell (make dialog column)
make static text with properties {static label:"in", min width:0}
make static text with properties {static label:"in", min width:0}
make static text with properties {static label:"in", min width:0}
end tell
tell (make dialog column)
make static text with properties {static label:"", min width:25}
end tell
end tell
end tell
end tell
set userResponse to show myDialog
if userResponse is true then
set docWidth to edit contents of myWidth as string
set docHeight to edit contents of myHeight as string
set docBleed to edit contents of myBleed as string
destroy myDialog
else
destroy myDialog
error number -128
end if
tell myDoc
if docHeight > docWidth then
set bigDim to docHeight
else
set bigDim to docWidth
end if
if bigDim ≤ 216 then
set buildSize to "1"
else if bigDim > 216 and bigDim ≤ 432 then
set buildSize to "2"
else if bigDim > 432 and bigDim ≤ 864 then
set buildSize to "4"
else if bigDim > 864 and bigDim ≤ 2160 then
set buildSize to "10"
end if
set newWidth to (docWidth / buildSize)
set newHeight to (docHeight / buildSize)
set newBleed to (docBleed / buildSize)
set document bleed top offset of document preferences to newBleed
set page width of document preferences to newWidth
set page height of document preferences to newHeight
end tell
set user interaction level of script preferences to origLevel
end tell
【问题讨论】:
-
对预期结果和实际错误消息的描述会有所帮助。
-
当我将高度和宽度设置为“5”时,它以 25% 的比例大小返回。即使我删除了所有其他 if-then 语句并只说“如果 bigDim ≤ 216 然后将 buildSize 设置为“1”,它也不起作用。它只是说 buildSize 没有定义——这只会发生在我的输入是 > 216。这毫无意义!
标签: applescript adobe-indesign