Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Parenthesis (<curved brackets>) won't appear when 'Replacing'.

    Help wanted · · · – – – · · ·
    3
    8
    100
    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.
    • Terry Gaff 0
      Terry Gaff 0 last edited by Terry Gaff 0

      Hi All, I’m hoping somebody has a solution for this one…
      With help from this forum many moons ago I created some complex (for me) macros to Find and Replace two types of text in a satellite tle (text) file.
      A quick background…The text file has 375,000 lines of text so obviously macros are a fantastic help, and the purpose is to find certain satellite names and change (correct) them to what I want. In this file, most satellite names are unique but others have words that appear more than once in the entire file ( e.g. a group of sats from the same country, perhaps launched years apart). For these ones I must include the satellite’s catalog number in the search terms (unlike it’s name, this number is unique) in order to find the precise satellite.

      Here’s an entry in the tle text file for an amateur satellite called AO-91 …
      AO-91
      1 43017U 17073E 20188.80679161 +.00000488 +00000-0 +43555-4 0 9996
      2 43017 097.7222 100.2954 0256689 347.6761 011.8247 14.78961550142025

      That bird is also commonly called FOX-1B and so the macro finds that satellite and replaces the name (which is unique in the file) with ‘AO-91 (FOX-1B)’ using this code…

              <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
              <Action type="3" message="1601" wParam="0" lParam="0" sParam="AO-91" />
              <Action type="3" message="1625" wParam="0" lParam="0" sParam="" />
              <Action type="3" message="1602" wParam="0" lParam="0" sParam="AO-91 (FOX-1B)" />
              <Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
              <Action type="3" message="1701" wParam="0" lParam="1608" sParam="" />
              <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
              <Action type="3" message="1601" wParam="0" lParam="0" sParam="AO-91" />
              <Action type="3" message="1625" wParam="0" lParam="0" sParam="" />
              <Action type="3" message="1602" wParam="0" lParam="0" sParam="AO-91 (FOX-1B)" />
              <Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
              <Action type="3" message="1701" wParam="0" lParam="1608" sParam="" />
      

      (I’m not sure why the code needs to be there twice but it does).

      So here’s my issue… Some other sats that need a name change need also to have their catalog number (“45119U” in line ‘1’ below) included in the search, like this one, which I want to change from ‘OBJECT J’ to ‘HO-107 (HUSKYSAT-1)’…

      OBJECT J
      1 45119U 19071J 20188.75098626 .00000896 00000-0 38634-4 0 9991
      2 45119 51.6436 270.0450 0012720 122.6541 237.5670 15.33623237 24087

      Here’s the code I use for that…

              <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
              <Action type="3" message="1601" wParam="0" lParam="0" sParam="^OBJECT J(?=\R1 45119U)" />
              <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
              <Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
              <Action type="3" message="1701" wParam="0" lParam="1" sParam="" />
              <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
              <Action type="3" message="1601" wParam="0" lParam="0" sParam="^OBJECT J(?=\R1 45119U)" />
              <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
              <Action type="3" message="1602" wParam="0" lParam="0" sParam="HO-107 (HUSKYSAT-1)" />
              <Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
              <Action type="3" message="1701" wParam="0" lParam="1608" sParam="" />
      

      The ultimate problem being that (unlike the first find/replace instance above), with this macro it will not include the curved brackets (parenthesis) either side of ‘HUSKYSAT-1’. This issue occurs anytime I use that code (albeit with different sat names).
      Sorry for the long winded explanation for a seemingly small problem but any help appreciated.

      Many thanks.
      Terry

      PeterJones 1 Reply Last reply Reply Quote 1
      • PeterJones
        PeterJones @Terry Gaff 0 last edited by PeterJones

        @Terry-Gaff-0 ,

        In your first macro, message 1625 is set to 0, which says it’s in normal search mode.

        In your second macro, message 1625 is set to 2, which says it’s in regular expression search mode. Parentheses have special meaning in regular expression search mode, and you need to use \( rather than ( in your edited macro’s message 1602 (the replacement).

        • docs: https://npp-user-manual.org/docs/searching/#searching-actions-when-recorded-as-macros
        1 Reply Last reply Reply Quote 2
        • Terry Gaff 0
          Terry Gaff 0 last edited by

          That works perfect Peter, many thanks indeed… saves me a ‘lot’ of hassle and headache.
          May I also ask… the first instance of code above… why must the 6 lines of code appear twice ?

          Regards.

          Terry

          PeterJones 1 Reply Last reply Reply Quote 1
          • PeterJones
            PeterJones @Terry Gaff 0 last edited by

            @Terry-Gaff-0 ,

            why must the 6 lines of code appear twice ?

            Are you sure it’s a “must”, or is that just what was recorded when you recorded the macro? I think it’s the latter, because the macro-recorder probably records some of those messages every time one of the inputs changes, even if those others haven’t changed. You probably just need one each for the 1700, 1601, 1625, 1702, 1701 – that’s one that you’ll have to experiment to see whether it works for you in your sequence.

            Terry Gaff 0 1 Reply Last reply Reply Quote 2
            • Terry Gaff 0
              Terry Gaff 0 @PeterJones last edited by

              @PeterJones I didn’t experiment too much Peter, that’s what the macro recorder spat out. I will however try out a few things and see how it goes. Many thanks again for your help and advice… very much appreciated. I just made a small donation so tell the Notepad++ author he/she owes you a coffee :)

              Terry

              Alan Kilborn 1 Reply Last reply Reply Quote 2
              • Alan Kilborn
                Alan Kilborn @Terry Gaff 0 last edited by

                @Terry-Gaff-0 said:

                May I also ask… the first instance of code above… why must the 6 lines of code appear twice ?

                Very very likely why this is is that, during macro recording, you performed the same button-press action TWICE in a row. I’ve done this; perhaps you were distracted by something for a quick second, and lost your place.

                Since the indicated parameters show this is a replace operation with Wrap around ticked (effectively a replace-all on the entire file), very likely the second invocation of the command does nothing (since everything that matched was replaced the first go-around).

                @PeterJones said:

                the macro-recorder probably records some of those messages every time one of the inputs changes, even if those others haven’t changed

                To be very clear, the macro recorder only does something here when one of the command buttons is pressed (e.g. Find Next, Replace, Mark, Find All, etc.). In between presses of these buttons while recording, you can change, for example, the Match case checkbox, a hundred times, and only its current value when a command button is pressed is recorded by the recorder.

                1 Reply Last reply Reply Quote 2
                • Terry Gaff 0
                  Terry Gaff 0 last edited by

                  Alan,
                  Thanks for your message. I’ll bear that in mind… I strongly suspect that the wrap around function has something to do with it. Perhaps, before I search for a certain text string (satellite name) I should return the ‘cursor’ to the start of the file.

                  Terry

                  Alan Kilborn 1 Reply Last reply Reply Quote 1
                  • Alan Kilborn
                    Alan Kilborn @Terry Gaff 0 last edited by

                    @Terry-Gaff-0

                    Ah, it didn’t hit me that your macro uses Replace and not Replace All (until I looked up the 1608 in Peter’s link above).

                    With Replace you could very well intend to run it twice in succession, in which case those “6 lines” would be duplicated in the recorder data.

                    It all depends upon what you are actually doing (which we don’t have a good grasp on). We trust that YOU know what you are doing. :-)

                    1 Reply Last reply Reply Quote 2
                    • First post
                      Last post
                    Copyright © 2014 NodeBB Forums | Contributors