Counter Find Replace Text with alert
Hello!
This code replace all text human, and added a Column Break before the human text.
If the text was replace more than want time, I want show an Alert.
My problem with this code is the Column Break is added 2 times, because looks the function is called 2 times and not 1.
Please, how can I do for show the Alert but don't add 2 Column Break each time the script find the text?
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.findWhat = "human\r";
app.changeTextPreferences.changeTo = "^M\human\r";
//this will show changes count
var counter = app.activeDocument.changeText().length;
if(counter>1){
alert("BECAREFULL! The text was replace "+ counter + " times");
}
app.activeDocument.changeText();
Thanks so much in advance.