I’m trying to build a script that does a find/replace on a QuarkXPress document. I would like the script to return a list of page numbers that have been modified. The find/replace part works ok, but I can’t figure out how to get a reference to a page (or the actual page numer) from the references returned by the search command.
This is what I came up with so far, but there must be a faster and cleaner way to do this…
set modifiedPages to {}
tell application "QuarkXPress Passport 6.5"
tell theQuarkDocument
set refsToOldSpelling to (a reference to (text of every story where it is oldSpelling))
set foundCount to count of refsToOldSpelling
if foundCount > 0 then repeat with j from 1 to count of pages
if modifiedPages does not contain j then
if (text of every text box of page j as string) contains oldSpelling then set modifiedPages to modifiedPages & j
end if
end repeat
set contents of refsToOldSpelling to newSpelling
end tell
end tell
Welcome at Macscripter. Are these lines useful for you?
Assuming on some pages will be the text “een woord” it will make the list with pagenumbers.
(But remember when changing texts you can cause the text flow to next pages. Be aware of that.)
Kjeld
set modifiedPages to {}
set oldSpelling to "een woord"
tell application "QuarkXPress Passport"
tell document 1
set theWordList to (object reference of every text of every story where it is oldSpelling)
repeat with eachItem in theWordList
set thisBox to object reference of text box 1 of eachItem
set ThisPage to name of page 1 of thisBox
set modifiedPages to modifiedPages & ThisPage
end repeat
end tell
end tell
Assuming you have a lot of, and bigger documents, this is speeding up the script a bit more.
property modifiedPages : {}
property oldSpelling : "een woord"
tell application "QuarkXPress Passport"
tell document 1
do script {MakeWordList}
end tell
end tell
script MakeWordList
tell document 1 of application "QuarkXPress Passport"
set theWordList to (object reference of every text of every story where it is oldSpelling)
repeat with eachItem in theWordList
set thisBox to object reference of text box 1 of eachItem
set ThisPage to name of page 1 of thisBox
set modifiedPages to modifiedPages & ThisPage
end repeat
end tell
end script