Community
    • Login

    [Bug] Running macro multiple times fails, line by line works

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    macrobug
    2 Posts 2 Posters 1.4k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Anton RaynovA Offline
      Anton Raynov
      last edited by

      Hey all, 7.5.6 64 bit here on windows 10. Having a file of some 35 lines in format:
      val:descr
      Which I want to flip to:
      descr = val,
      So I did a fast macro:
      <Macro name=“buggy” Ctrl=“no” Alt=“no” Shift=“no” Key=“0”>
      <Action type=“0” message=“2442” wParam=“0” lParam=“0” sParam=“” />
      <Action type=“0” message=“2177” wParam=“0” lParam=“0” sParam=“” />
      <Action type=“0” message=“2180” wParam=“0” lParam=“0” sParam=“” />
      <Action type=“0” message=“2451” wParam=“0” lParam=“0” sParam=“” />
      <Action type=“1” message=“2170” wParam=“0” lParam=“0” sParam=" " />
      <Action type=“1” message=“2170” wParam=“0” lParam=“0” sParam=“=” />
      <Action type=“1” message=“2170” wParam=“0” lParam=“0” sParam=" " />
      <Action type=“0” message=“2179” wParam=“0” lParam=“0” sParam=“” />
      <Action type=“1” message=“2170” wParam=“0” lParam=“0” sParam=“,” />
      <Action type=“0” message=“2300” wParam=“0” lParam=“0” sParam=“” />
      <Action type=“0” message=“2453” wParam=“0” lParam=“0” sParam=“” />
      </Macro>
      When I run it on line by line by leaving some time between clicks - everything is fine. If I click faster, or run it till the end of file - at least 3-4 lines are corrupted. Haven’t seen this behavior with previous versions of notepad++. Any idea?

      1 Reply Last reply Reply Quote 0
      • guy038G Offline
        guy038
        last edited by guy038

        Hello, Anton, and All,

        If you want to run your buggy macro, Nth times, be sure that :

        • The cursor is located at the very beginning of the first line val:descr

        • A physical line-break ( CR+LF or LF ) exists at the end of the nth line

        As for me, I did not notice that issue ! Even, holding down the 3 keys of the assigned shortcut ( Ctrl + Shift + = ), the macro changes each line, one after another, without any trouble ;-)

        Here is, below, my code of the buggy macro, with N++ v7.5.6, on an ( old ! ) Win XP SP3 system

               <Macro name="buggy" Ctrl="yes" Alt="yes" Shift="no" Key="187">
                    <Action type="0" message="2442" wParam="0" lParam="0" sParam="" />
                    <Action type="0" message="2177" wParam="0" lParam="0" sParam="" />
                    <Action type="0" message="2180" wParam="0" lParam="0" sParam="" />
                    <Action type="0" message="2451" wParam="0" lParam="0" sParam="" />
                    <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
                    <Action type="1" message="2170" wParam="0" lParam="0" sParam="=" />
                    <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
                    <Action type="0" message="2179" wParam="0" lParam="0" sParam="" />
                    <Action type="1" message="2170" wParam="0" lParam="0" sParam="," />
                    <Action type="0" message="2300" wParam="0" lParam="0" sParam="" />
                    <Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
                </Macro>
        

        A second and faster solution could be to execute a Search/Replacement, with the the litteral strings, in normal search mode, on all text of a previous selection. So :

        • First, select your block of val:descr lines

        • Open the Replace dialog ( Ctrl + H )

        • Find what : val:descr

        • Replace with: descr = val,

        • Tick the In selection option

        • Select the Normal search mode

        • Click on the Replace All button

        Voilà !

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors