Does anyone have any ideas on this. I’ve had this problem for a while and thought I’d revisist it. The following script will not find the user-entered search string in QXP 6.5. If I hard code in a string to searrch for, it works fine, but if I use a search string as a variable it will fail to find the text. Any ideas. I’m at a total loss.
display dialog "Enter text to find in the Quark file:" default answer "" buttons {"Cancel", "OK"} default button 2
set the search_string to the text returned of the result
tell application "QuarkXPress Passport"
tell document 1
repeat with x from 1 to (the count of pages)
tell page x
repeat with i from 1 to count of every text box
if text of text box i contains search_string then
display dialog "text exists"
else
display dialog "text does not exist"
end if
end repeat
end tell
end repeat
end tell
end tell
Thanks CarbonQuark. It works if it iterates down through the pages and text boxes (as in your script).
What’s annoying is that, with a hard coded string, it works without that iteration scheme. I assume it would be faster without the iteration. Any idea why the non-iterated way won’t work. Is it a problem with my syntax or just not a bug in Quark?
I had no luck figuring out why it works when you hard code the search string and does not when you pull from dialog text.
Maybe one of the Ultra Applescript Gurus could answer that
I tested both methods and they seemed to return the result with the same speed.
After further review it looks like it was a syntax problem.
Try this:
display dialog "Enter text to find in the Quark file:" default answer "" buttons {"Cancel", "OK"} default button 2
set the search_string to the text returned of the result as text
tell application "QuarkXPress Passport"
tell document 1
if (text of every story as string) contains search_string then
display dialog "text exists"
else
display dialog "text does not exist"
end if
end tell
end tell
Thanks for the help with the syntax. That works. It also yields much faster performance when processing multiple files than having the Apple Script iterate through boxes.