11439Re: [Clip] Re: Delete thousands of lines
- Jan 2, 2004Hi Chuck,
Here's another attempt.
It only works on the current email message. The next email message is identified by locating the first line after the cursor that starts with the word "From".
It deletes all attachment sections following the starting cursor position until it reaches an attachment section that has no tabfilename= line within its first few lines. It preserves the prefix text (assumed to be email text) and suffix text (everything following the first section with no attachment file name). From your example it appears that the message ends with one of those boundary lines. That last boundary line is treated as part of the suffix text and is not removed. I thought perhaps it could cause problems with your email program if it was missing.
Its very fast. I altered your test file to put over 15000 lines in each attachment. I discovered that most of the typical manners of deleting or pasting or inserting over these large blocks worked very slowly when done with clip instructions. I don't know why these were so slow since (for example) doing similar tasks manually were not delayed. Fortunately I discovered that using ^!InsertSelect ^$GetFileText(filename.txt)$ to replace thousands of selected lines didn't have this problem. Otherwise, I would be suggesting a Perl solution (were you aware that NoteTab clips can run Perl?)
It doesn't really work as you said you wanted it to. You're not prompted for a search string.
Instead, you should save any attachments in the current message that you want to keep. Then position the cursor within the text message (i.e., below its "------=_NextPart_" line) and run the clip. The line count and file name associated with each deleted section is preserved.
If this works well, you could make a new clip with a clip wizard that helps you locate proper starting points and then automatically runs this clip with a ^!Clip command.
To copy this clip without broken lines, copy/paste from somewhere around this page:
^!Continue Cursor position should be in or below email text (above attachments). If necessary Cancel and reposition the cursor.
^!SetHintInfo Working ...
;Operate only within this message - next starts with "From" in col 1
;Or if no next message, operate to end of file
^!Find "^From" RS
^!IfError Next Else Skip_1
;Copy from starting point to end of message to temporary buffer
^!Menu Edit/Paste New
^!Find "------=_NextPart_" TIS
;Don't delete from 1st section of message (s/b text)
^!If ^%Index%=1 Next Else Skip_3
^!AppendToFile "^$GetLibraryPath$delatt.txt" ^$GetSelection$
^!Find "^P^P" IS
^!Find "^P^Tfilename="" THS
;If attachment has no filename, preserve all remaining attachments in file
^!Find "[^"]*" RS
^!Find "------=_NextPart_" IS
^!AppendToFile "^$GetLibraryPath$delatt.txt" *** "^%attachnames^%Index%%"(^%count% LINES DELETED)^%NL%
;leave last boundary in place
^!If ^%Index%=1 Error
^!AppendToFile "^$GetLibraryPath$delatt.txt" ^%NL%^$GetSelection$
^!IfFileExist "^$GetLibraryPath$delatt.txt" Next Else Error
^!Info Error - Cursor was not within message text or 1st boundary had no filename in expected format.
- << Previous post in topic