Hello. I am trying to get the following script to work as a classic script with Quark 4.11. What I would like it to do is loop through a list of style names and then go through another loop that reapplies that style sheet within the document.
It almost works. On larger documents, it fails with a memory error and I was hoping someone could clarify what I could do to keep the memory error from occurring. I believe that the variable “theGraphs” gets overloaded with references to certain styles that appear many times and then the script fails. I have gotten the script to work with 2 or 3 styles on 200 page documents, but I would like it to work with about 8-10 styles on any document. Any ideas are greatly appreciated…and yes, it is a cruel hack of an older Sal Soghoian script…apologies to Sal.
tell application "QuarkXPress™ 4.11"
activate
set theGraphs to {}
set megaList to {"style_name1","style_name2","style_name3","style_name4"}
try
repeat with x from 1 to count of megaList
tell document 1
set styleToSearchFor to item x of megaList as text
set theGraphs to (the object reference of ¬
every paragraph of story 1 of current box whose ¬
name of style sheet is styleToSearchFor)
if the class of theGraphs is not list then
copy (coerce theGraphs to list) to theGraphs
end if
repeat with i from (number of theGraphs) to 1 by -1
set style sheet of paragraph 1 of (item i of theGraphs) to null
set style sheet of paragraph 1 of (item i of theGraphs) to styleToSearchFor
end repeat
end tell
beep 2
end repeat
on error
beep 4
end try
end tell