Community
    • Login

    Windows exclamation macro beeps.. at what ?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 4 Posters 923 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.
    • Terry Gaff 0T Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              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 Online
                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

                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