• Login
Community
  • Login

Windows exclamation macro beeps.. at what ?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 4 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.
  • T
    Terry Gaff 0
    last edited by Jun 9, 2020, 2:57 PM

    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
    • P
      PeterJones
      last edited by Jun 9, 2020, 3:59 PM

      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
      • T
        Terry Gaff 0
        last edited by Jun 9, 2020, 8:00 PM

        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

        A 2 Replies Last reply Jun 9, 2020, 8:05 PM Reply Quote 0
        • A
          Alan Kilborn @Terry Gaff 0
          last edited by Jun 9, 2020, 8:05 PM

          @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
          • A
            Alan Kilborn @Terry Gaff 0
            last edited by Jun 9, 2020, 8:15 PM

            @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
            • G
              guy038
              last edited by guy038 Jun 9, 2020, 8:33 PM Jun 9, 2020, 8:32 PM

              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
              5 out of 6
              • First post
                5/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors