Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #7796
    WmMitchell
    Participant

    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!

    #7803
    Yutaka Emura
    Keymaster

    WmMitchell wrote:
    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!

    “eeFindNext | eeReplaceAll” should be enough, and you shouldn’t use shell.SendKeys(“{CTRL DOWN}{CTRL UP}”);.

    Can you simplify your test program and a sample file, and email me at [email protected] ? I will try to reproduce your problem, and fix it if it is a bug of EmEditor.
    Thank you.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.