View Single Post
Old 11-12-2012, 08:28 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
Functions are the key to avoid code repetition
Code:
function myReplace(search_string, replace_string) {
   var active_doc = app.activeDocument;
 
   var text_frames = active_doc.textFrames;
 
   if (text_frames.length > 0)
   {
       for (var i = 0 ; i < text_frames.length; i++)
         {
             var this_text_frame = text_frames[i];
              var new_string = this_text_frame.contents.replace(search_string, replace_string);
           
              if (new_string != this_text_frame.contents)
                  {
                       this_text_frame.contents = new_string;
                  }
         }
   }
}

myReplace(/_/gi, " ");
myReplace(/ASY - /gi, "ASY ");
...
devnull69 is offline   Reply With Quote
Users who have thanked devnull69 for this post:
BrianEdL (11-12-2012)