I want to remove any lines from a file that contain certain strings. Thinking macros were an obvious choice, I substituted any lines that contained the strings with XXX, then made a macro that did a FIND NEXT followed by 2x backspace to delete the XXX and the newline.
Next I tried Run macro until end of file, which only seemed to run the macro one time. Next I tried Run macro X times, and put in 5000 times to make sure it got to the end of file. The macro hit the end of file, then kept popping up a 'String not found' dialog, then deleting 2 characters from wherever the cursor happened to be. I could not stop it, and ended up having to kill the program.
There doesn't seem to be any way to stop a macro from repeating if it reaches an error condition. Is there some way to do this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The Run Until End of File option doesn't work when the macro deletes the current line and remains there. This is due to a bug in NP++, which halts macro playback when
if ( currLine == _pEditView->getCurrentLineNumber() ) // line no. not changed?
This condition is too restrictive. I believe it should instead be
if (( currLine == _pEditView->getCurrentLineNumber() ) // line no. not changed?
&& (lastLine <= int(_pEditView->execute(SCI_GETLINECOUNT)) - 1)) // and no lines removed?
In the meantime, for your case, this seems to work:
(1) Use Ctrl-F to search for "XXX".
(2) Close the Find dialog.
(3) Record keystroke macro: <F3>, <End>, <Home>, <Home>, <Ctrl-Down>, <Del>
(4) Run the macro a fixed number of times.
Regards.
Greg
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to remove any lines from a file that contain certain strings. Thinking macros were an obvious choice, I substituted any lines that contained the strings with XXX, then made a macro that did a FIND NEXT followed by 2x backspace to delete the XXX and the newline.
Next I tried Run macro until end of file, which only seemed to run the macro one time. Next I tried Run macro X times, and put in 5000 times to make sure it got to the end of file. The macro hit the end of file, then kept popping up a 'String not found' dialog, then deleting 2 characters from wherever the cursor happened to be. I could not stop it, and ended up having to kill the program.
There doesn't seem to be any way to stop a macro from repeating if it reaches an error condition. Is there some way to do this?
The Run Until End of File option doesn't work when the macro deletes the current line and remains there. This is due to a bug in NP++, which halts macro playback when
if ( currLine == _pEditView->getCurrentLineNumber() ) // line no. not changed?
This condition is too restrictive. I believe it should instead be
if (( currLine == _pEditView->getCurrentLineNumber() ) // line no. not changed?
&& (lastLine <= int(_pEditView->execute(SCI_GETLINECOUNT)) - 1)) // and no lines removed?
In the meantime, for your case, this seems to work:
(1) Use Ctrl-F to search for "XXX".
(2) Close the Find dialog.
(3) Record keystroke macro: <F3>, <End>, <Home>, <Home>, <Ctrl-Down>, <Del>
(4) Run the macro a fixed number of times.
Regards.
Greg