Hi,
I have written one applescript for Quarkxpress. The script finds each and every number in the currently opened quark file and adds 24 to every number.
The script works very fine but when it goes on and on, it becomes slower and slower in execution.
For example, if the quark file consist 22 page, this script approximately runs for 60-70 minutes.
My script is:
run script index1
display dialog "Done."
script index1
tell application "QuarkXPress"
activate
tell document 1
tell text box 1
tell story 1
set textcount to count of every word
repeat with i from 1 to textcount
set numberCheck to true
set HCheck to false
set ACheck to false
set BCheck to false
set RCheck to false
try
set chars to word i as integer
set chars_f to words (i - 1) through (word i) as string --& chars as string
--display dialog chars_f
if (chars_f contains "-") or (chars_f contains "+") or (chars_f contains return) then
set numberCheck to false
if (chars_f contains "H-") then
set HCheck to true
end if
if (chars_f contains "A-") then
set ACheck to true
end if
if (chars_f contains "B-") then
set BCheck to true
end if
if (chars_f contains "R-") then
set RCheck to true
end if
end if
on error
set numberCheck to true
set Achars to word i
set firstchar to item 1 of Achars
if ((count of Achars) is greater than 3 or (count of Achars) is equal to 2) then
set Achars to items 2 through last character of Achars
end if
try
set chars to Achars as integer
on error
set numberCheck to false
end try
if (numberCheck is true and chars is less than 999) then
set chars to (chars as integer) + 24
set word i to firstchar & chars
end if
set numberCheck to false
end try
if (numberCheck is true and chars is less than 999) then
set chars to chars + 24
set word i to chars
end if
if (HCheck is true and chars is less than 999) then
set chars to chars + 24
set word i to chars
end if
if (ACheck is true and chars is less than 999) then
set chars to chars + 24
set word i to chars
end if
if (RCheck is true and chars is less than 999) then
set chars to chars + 24
set word i to chars
end if
end repeat
end tell
end tell
end tell
end tell
end script
Could any one help me how to increase the speed of this script.
Thanks,
Gopal