Community
    • Login

    Windows exclamation macro beeps.. at what ?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 4 Posters 388 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.
    • Terry Gaff 0T
      Terry Gaff 0
      last edited by

      Hi all,

      I very regularly run several macros on a large text file. Most of these macros contain many searches and edits of various satellite names. Sometimes, when I run a macro, I hear windows exclamation beeps because the macro has run across a (search?) error and so it continues on to the next instruction in the macro until the end (as normal). Is there a way I can get Notepad++ to tell me where in the text file this error occurred ?

      Thanks.

      Terry

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        In my experience, the search feature only makes a noise when there is nothing found, or an error in your search expression itself. Answering “where in the file” nothing is found is a rather difficult question to answer (or easy: it wasn’t found anywhere in the file).

        As for narrowing it down more than that: if you run across the alert sound, I would recommend running each of the searches from your macro one-at-a-time until you determine which search failed.

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

          Many thanks Peter… well, when I get the beep that’s what I do but it’s a rather laborious process. That’s why I thought there might be a better way to pinpoint the error.

          Terry

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

            @Terry-Gaff-0

            This sounds like a potentially dangerous situation.
            Well, for your data, not for you.

            Although it isn’t for everyone, you’d have more control if you scripted your edits with a scripting language. You’d have to do double effort: Find your data first, then replace it (instead of just a blind replace), but you’d have much more control over where failures occur and what to do about them.

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

              @Terry-Gaff-0

              Even something as simple as this can tell you where such an error occurs, and aborts (this sample is in the Pythonscript plugin language):

              # -*- coding: utf-8 -*-
              
              from Npp import editor
              
              def my_replaces():
              
                  matches = []
                  editor.search('search1', lambda m: matches.append(m.span(0)))
                  if len(matches) == 0:
                      print('oops...search1 failed')
                      return
                  editor.replace('search1', 'replacement1')
              
                  matches = []
                  editor.search('search2', lambda m: matches.append(m.span(0)))
                  if len(matches) == 0:
                      print('oops...search2 failed')
                      return
                  editor.replace('search2', 'replacement2')
              
                  # etc, etc
              
              my_replaces()
              
              1 Reply Last reply Reply Quote 1
              • guy038G
                guy038
                last edited by guy038

                Hello, @terry-gaff-0 and All,

                I second what Alan said :

                This sounds like a potentially dangerous situation.
                Well, for your data, not for you.

                Indeed, you must define what to do, when any of your searches is unsuccessful. If you’re using the regular expression search mode, it usually means that some templates, in your data, are not taken in account by the overall regex search expression !

                Best regards,

                guy038

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