• Login
Community
  • Login

Macro not recording/performing Find and Replace task.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 3 Posters 389 Views
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.
  • A
    Aaron Bishdou
    last edited by Oct 24, 2022, 7:30 PM

    The subject was quite old in this thread, and upon prompt i chose to open a new Conversation referring to this old one:
    Re: Creating and running macros

    I want to modify a text/log file to make all the messages line up as columns example:

    0Z","@mt":"Class: Program           Msg:HMI star
    0Z","@mt":"Class: Program           Msg:Entering
    0Z","@mt":"Class: Program           Msg:No comma
    5Z","@mt":"Class: Program           Msg:Number o
    3Z","@mt":"Class: PlcLogSettingsManagerMsg:PlcLo
    8Z","@mt":"Class: ApplicationLifetimeManagerMsg:
    8Z","@mt":"Class: ApplicationLifetimeManagerMsg:
    8Z","@mt":"Class: ApplicationLifetimeManagerMsg:
    2Z","@mt":"Class: ApplicationLifetimeManagerMsg:
    2Z","@mt":"Class: Program           Msg:Creating
    0Z","@mt":"Class: MainForm          Msg:MainForm
    0Z","@mt":"Class: MainForm          Msg:MainForm
    0Z","@mt":"Class: MainForm          Msg:MainForm
    0Z","@mt":"Class: MainForm          Msg:MainForm
    

    I just used “Alt+Mouse Selection” to snip out a portion of the log file to show you what I’m trying to do.

    As you can see the “Class: PlcLogSettingsManager” is pushing the “Msg:” column out of alignment. I thought to just record a macro to replace the “Class:” messages with a shorter text string and the right amount of spaces to make the columns line up. When I record a macro to “Find and Replace”, it doesn’t work. What am I doing wrong, or is there a better way to accomplish the task?

    Any help is appreciated. Thanks!

    A N 2 Replies Last reply Oct 24, 2022, 7:32 PM Reply Quote 0
    • A
      Aaron Bishdou @Aaron Bishdou
      last edited by Oct 24, 2022, 7:32 PM

      BTW, here is the macro from the shortcuts.xml file:

              <Macro name="Align columns" Ctrl="no" Alt="no" Shift="no" Key="0">
      
                  <Action type="0" message="2178" wParam="0" lParam="0" sParam="" />
      
                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
      
                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="PlcLogSettingsManager" />
      
                  <Action type="3" message="1625" wParam="0" lParam="0" sParam="" />
      
                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="PlcLogSettingsMgr  " />
      
                  <Action type="3" message="1702" wParam="0" lParam="0" sParam="" />
      
                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
      
                  <Action type="0" message="2178" wParam="0" lParam="0" sParam="" />
      
                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
      
                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="ApplicationLifetimeManager" />
      
                  <Action type="3" message="1625" wParam="0" lParam="0" sParam="" />
      
                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="ApplctionLifeTmMgr" />
      
                  <Action type="3" message="1702" wParam="0" lParam="0" sParam="" />
      
                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
      
              </Macro>
      
      A 1 Reply Last reply Oct 24, 2022, 7:55 PM Reply Quote 0
      • A
        Alan Kilborn @Aaron Bishdou
        last edited by PeterJones Oct 26, 2022, 12:53 PM Oct 24, 2022, 7:55 PM

        @Aaron-Bishdou

        Not sure why you have two Copy commands (message=“2178”) in there…you didn’t mention…

        Anyway, I had “luck” with your macro if I changed the message=“1702” lines to contain lParam=“770” instead of the “0” you had in there.

        “0” is not ideal because it specifies a backward search without wrap. Thus, if your caret is at the first line of your data when you run the macro, nothing is going to happen.

        “770” tells the macro system to do Match case and Wrap around in a top-to-bottom direction for the Replace All. Thus, it works…

        I said “luck” earlier, because while a replacement was made with my changes, it didn’t have the right content to make the columns “line up”. I used your find/replace text just as you had it in the macro.

        BTW if you want to “crack” your find/replace macros in the future, this SECTION of the user manual tells you how.

        1 Reply Last reply Reply Quote 3
        • N
          Neil Schipper @Aaron Bishdou
          last edited by Oct 26, 2022, 2:40 AM

          @Aaron-Bishdou Treat the tuning of a Find & Replace operation as a separate and preliminary task before thinking about macros. It is rare to have to examine npp’s representation of F&R ops in shortcuts.xml at all.

          The transformation you are hoping for does not seem complex. If you want help, show explicitly the expressions you are trying in the Find and the Replace fields along perhaps with optional settings in the F&R dialog.

          Also, think about whether your sample text captures all the anticipated variation (field names & lengths) in your log files.

          1 Reply Last reply Reply Quote 4
          4 out of 4
          • First post
            4/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors