Windows exclamation macro beeps.. at what ?



  • 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



  • 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.



  • 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



  • @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.



  • @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()
    


  • 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


Log in to reply