I’ve worked (and received help) to get an applescript to perform a series of Find and Replace tasks in InDesign but would love a dialog that tells me how many of each task it’s performed. Like the regular F&R does. How would i write code to have my script do that?
I have it generating a dialog saying what is being done when it starts and a dialog that says that it is “Done”.
Also, how could I have it play a beep or sound when it’s done too?
do you mean that you want a dialog that tells you how many occurences were replaced for a a certainsearch? I’m not sure I quite understnad what you want to do. If your answer to my question is yes, then the
search for <string> replacing with <string>
command returns a list of the texts that were replaced. By using count command with this list, you can find out the number of replacements.
This is the Find and Replace we created to make certain text items all superscript. If I did the F&R manually in InDesign it presents a dialog saying “# occurrences have been changed” after it’s performed the “replace all”. If you don’t have InDesign the Word F&R behaves very similar to give you an idea. I’d like for this script to provide the same kind of dialog for ALL the changes in one dialog list. Something like:
"# of ™ occurrences have been made SuperScript
I’m really new at this Applescript stuff so feel free to treat me like a dummy. How and where would I place your suggested commands to get that kind of result?
ok, that’s very doable. Just keep track of the number of each type of character during the script.
set myfoundcharacter to search for "™" with change attributes {applied character style:myssstyle}
set countTMChar to count (myfoundcharacter)
set myfoundcharacter to search for "®" with change attributes {applied character style:myssstyle}
set countRChar to count (myfoundcharacter)
--etc.
at the end you can then have a dialog like
display dialog countTMChar & "of ™ occurences have been made SuperScript" & return & countRChar & "of ® occurrences have been made SuperScript" & return --etc.
yeah, I’ve had that error too. what Andy said will probably work. I’ve also just stuck an empty string at the beginning of the dialog:
display dialog "" & countTMChar & "of ™ occurences have been made SuperScript" & return & countRChar & "of ® occurrences have been made SuperScript" & return --etc.