Re: [Clip] Delete thousands of lines
- Hi Chuck, Larry, others,
Happy New Year!!
Chuck, I think you/we need to study your file a bit more. If you want some help with this, you could create a test file, zip it, and temporarily post it in our group's Yahoo files area. As Larry pointed out, there are probably specific formats that define both the beginning and end of an attachment. I use Eudora; it decodes, saves and strips attachments from messages before I even see them.
Dick, I believe Outlook Express uses a non-standard email file format.
Larry, you should stay away from the ^!ClearVariables and ^!ClearValues commands. There are some clips that when rerun, make use of variables previously set. ^!ClearVariables clears all variables, not just the ones used by the current clip. It even clears variables previously defined as permanent variables. If you have a clip that uses a lot of variables that need not remain in memory at the end, you can have a section the clear just your variables, e.g.,
Chuck, you should try my Clipcode Syntax clip package. It is great for jarring the memory when you don't write clips very often, but also convenient for everyone. You can choose from lists of keywords, select commands and functions, and be prompted for the required parameters. Or, if you type a few letters that are in a particular command of function and then run the clip, it will find only matching keywords. For example, while editing your clip, you can type in the word "count", and run the syntax clip. You could then choose among:
After highlighting "^$StrCount$", pressing Ok would:
replace the word you typed ("count") with
...and open a clip wizard to enter or select each parameter.
There are also options to look up terms in clip help and perform other functions. It won't help much with the logic of your clip, but does have some template code (e.g., for loops, wizards, math, etc.) in it. For example, running it on "loop" would insert this into your clip and then prompt for Howmanyloops:
^!If ^%Index%>^%LoopCount% EndLoop
*** Do something ***
The package is in our Yahoo files area and is compatible with current versions of all NoteTab variants (Light, Standard and Pro). However, the ^!Menu commands portion was adapted from Wayne VanWeerthuizen Menu clip which includes all the Pro Menu commands, some of which are not supported by NoteTab Standard/Light.
To access the files area, you must have a yahoo id associated with your group membership. If you have problems try this site: http://groups.yahoo.com/memwiz
- --- In firstname.lastname@example.org, Sheri <silvermoonwoman@c...> wrote:
> Hi Chuck, Larry, others,Same to you, as well. May this be a fortuitous and joyful year.
> Happy New Year!!
> Chuck, I think you/we need to study your file a bit more. ......You got it. (I am a web designer - very good with Php right now - C++
in my past - the wayback machine.)
Download these two short text files:
Readme explains it all - hopefully. :-)
> I use Eudora; it decodes, saves and strips attachments from messagesbefore I even see them.
(Maybe I should switch.) ô¿Ô¬
> Chuck, you should try my Clipcode Syntax clip package.I downloaded it and will install it. (After a bike ride - it's >
50º here today!)
- Hi 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.