Jag har ett skript för InDesign som låter användaren ångra ur en lista. Detta fungerar bra när jag kör skriptet självt, men när det körs inifrån en script bundle av en "caller" kan InD inte ångra.
Jag bifogar en fungerande och en icke fungerande version.
Caller:
set myPathToMe to path to me as Unicode text
tell me to set text item delimiters to ":"
set myName to text item -2 of myPathToMe
tell me to set text item delimiters to ""
set myScriptFolderPath to (path to resource "Scripts") as Unicode text
set myMainScript to alias (myScriptFolderPath & "main2.scpt")
tell application "Adobe InDesign CS5"
try
set myDocName to name of document 1
on error
set myDocName to "[no document]"
end try
set myResult to (do script myMainScript undo name myName undo mode entire script)
end tell
skript:
set myExceptions to {"Update PageDateline Boxes", "Shuffle Pages", "Modify Section Settings"}
set myL to {}
tell application "Adobe InDesign CS5"
set myDoc to active document
tell myDoc
set myHistoryList to undo history
repeat with I from 1 to count myHistoryList
set end of myL to (I & ". " & item I of myHistoryList) as Unicode text
end repeat
if myHistoryList is not {} then
set myChoice to choose from list myL with prompt "Till och med vilket moment vill du ångra?" & return & "Det senaste momentet har nummer 1."
if myChoice is not false then
tell me to set text item delimiters to "."
set myNumber to text item 1 of item 1 of myChoice
tell me to set text item delimiters to ". "
if text item -1 of item 1 of myChoice is not in myExceptions then
repeat myNumber times
try
undo
on error err
display dialog err
end try
end repeat
else
display alert "Ogiltigt val."
end if
end if
else
display alert "Je ne regrette rien!"
end if
end tell
end tell