EmEditor (text editor) Forum Index
   Questions and Answers about Macros
     Automated S&R?
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
WmMitchell
Posted on: 11/7/2009 5:15 am
Just popping in
Joined: 11/1/2009
From:
Posts: 5
Automated S&R?
I posted this in the regex group, which might have been a mistake. I think that it might actually be better here.

I'm not getting consistent results with the S&R macro below. If I don't put:

document.selection.StartOfDocument(false);
shell.SendKeys("{CTRL DOWN}{CTRL UP}");

a lot in the document to periodically force the cursor to the top of the document being edited, the macro doesn't replace _all_ items, even though I have put the option eeReplaceAll in every single S&R instance. Even forcing the cursor up to the top of doesn't make the S&R perform consistently and I have to manually invoke this script 2 or 3 times.

------------------------------------------------------------
document.selection.StartOfDocument(false);
shell.SendKeys("{CTRL DOWN}{CTRL UP}");

document.selection.Replace(". ",". ",eeFindNext | eeReplaceAll);
document.selection.Replace(". ",". ",eeFindNext | eeReplaceAll);
document.selection.Replace(". ",". ",eeFindNext | eeReplaceAll);
document.selection.Replace(". ",". ",eeFindNext | eeReplaceAll);
document.selection.Replace(". ",". ",eeFindNext | eeReplaceAll);
document.selection.Replace("? ","? ",eeFindNext | eeReplaceAll);
document.selection.Replace("? ","? ",eeFindNext | eeReplaceAll);
document.selection.Replace("! ","! ",eeFindNext | eeReplaceAll);
document.selection.Replace("! ","! ",eeFindNext | eeReplaceAll);
document.selection.Replace(": ",": ",eeFindNext | eeReplaceAll);
document.selection.Replace(": ",": ",eeFindNext | eeReplaceAll);
document.selection.Replace("Dr. ","Dr. ",eeFindNext | eeReplaceAll);
document.selection.Replace("Mr. ","Mr. ",eeFindNext | eeReplaceAll);
document.selection.Replace("Mrs. ","Mrs. ",eeFindNext | eeReplaceAll);
document.selection.Replace("Lt. ","Lt. ",eeFindNext | eeReplaceAll);

document.selection.StartOfDocument(false);
shell.SendKeys("{CTRL DOWN}{CTRL UP}");
document.selection.Replace("1/4","¼",eeFindNext | eeReplaceAll);
document.selection.StartOfDocument(false);
shell.SendKeys("{CTRL DOWN}{CTRL UP}");
document.selection.Replace("1/2","½",eeFindNext | eeReplaceAll);
document.selection.StartOfDocument(false);
shell.SendKeys("{CTRL DOWN}{CTRL UP}");
document.selection.Replace("3/4","¾",eeFindNext | eeReplaceAll);
------------------------------------------------------------

I saw an example of a macro in what looks like an old forum for EmEditor and subsituted eeFindNext for eeFindReplaceQuiet, but that didn't make the macro work repeatedly until all instances found and fixed.

What can be done to ensure the macro "loops" through each function until done, pls?

Thanks!
Flat Previous Topic | Next Topic


Subject Poster Date
 » Automated S&R? WmMitchell 11/7/2009 5:15 am
     Re: Automated S&R? Yutaka 11/8/2009 9:29 am

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文