Search-and-replace is one single operation. Unless for some specific situation, you don't have to search first. (Besides, if you do search first and store the results, they will not be valid anymore after the change.)
TextFrames support both methods 'findText' and 'changeText', so this snippet
app.findTextPreferences = null;
app.findTextPreferences.findWhat = "something";
app.changeTextPreferences.changeTo = "anything";
alert ("This is a "+app.selection.constructor.name);
works just fine if you select a text frame and run it.
1 person found this helpful
Since you appear to be unwilling to search the forum, I've done it for you. Look at this topic:
It is all about how to convert a CS2 search script to CS3.
Thank you very much jongware.