Loading ...
Sorry, an error occurred while loading the content.

Delete thousands of lines

Expand Messages
  • Chuck Anderson
    I m already somewhart familiar with the cip language and have written some pretty basic stuff - although I do it so infrequently that it s always a major
    Message 1 of 6 , Dec 30, 2003
    • 0 Attachment
      I'm already somewhart familiar with the cip language and have written
      some pretty basic stuff - although I do it so infrequently that it's
      always a major effort for me to create new ones.

      I'll explain what I want to do by copying the thread that I started in
      the notetab basic list.

      I believe that what I want to do is set a mark (save a location) -
      search for some text that is 100's of lines away - scroll up a couple
      of more lines and then delete all of the text between those two points.

      Here's the original thread.

      > Hi Chuck,
      >
      > At 02:03 AM 12/30/03 -0000, you wrote:
      > >I'm trying to delete large attachments from my email inbox. I
      would
      > >like to select all of the text from point A to point B, where the
      > >location of Point B is thousands of lines away. I essentially
      need to
      > >search for it. Or, I can set a bookmark at the beginning, find the
      > >end and set another bookmark.
      > >
      > >How do I select all the text between those two points so I can
      delete
      > >it?
      > >
      > >Or, if there is another method, how do I delete several thousand
      lines
      > >of text? (line 15,400 to line 34,000)
      >
      > You can display line numbers in the gutter of the left margin by
      going to
      > the menu bar and selecting View/Line Numbers. Then scroll down to
      the
      > first line you want to delete and select it. Next scroll down to
      the last
      > line you want to delete and hold down the shift key and select it
      and press
      > the delete key.
      >
      > Regards,
      >
      > Larry
      > lrt@n... e¿ê

      Thanks, Larry. That works great. I can use that.

      But, I'm so used to editors that let you set a mark - navigate to
      another place in the document - and then select everything between
      there and the mark. I was hoping for something similar. It would be
      a lot more efficient if I could search to find the next spot in the
      file, or had some other automated of way of getting there. Goto Line
      number, Goto Bookmark, and Find all seem to unselect the first selection.

      Here's an example of what I'm trying to do; deleting four image
      attachments from one email message:

      There's a line at the beginning of each image attachment that says:
      ------=_NextPart_000_0000_01C3BE29.B3DF5380
      [That's a randomly generated delimiter]

      Ideally, I would like to select the first line of the first image (as
      you said) and then find:"------=_NextPart_000_0000_01C3BE29.B3DF5380."
      That would take me to the beginning of the next image and I could
      scroll up a couple of lines, shift-select, and then delete the first
      image attachment (that way I can skip over the description fields that
      appear at the beginning of each image to leave a text record of having
      deleted the image in the email message text).

      Then I scroll down to the beginning of the next image (gobbledy-gook
      binary characters - a jpeg file), select that line, repeat my find,
      shift-select, and delete the second image (leaving the description
      fields again).

      So, ... What I want to know is; is there another way to navigate
      through the document besides scrolling without losing the initial
      selection? (I'm probably getting into "clipsville" now.)

      Thanks,
      Chuck

      Any help would be appreciated. My guess is that there is a already a
      clip that does this. ?? (Or something similar and I could look at
      that clip and figure out how to change it.)
    • Sheri
      You said the delimiter is randomly generated. I have assumed the first part of it not random and that you don t want to enter anything. Try this clip. It
      Message 2 of 6 , Dec 31, 2003
      • 0 Attachment
        You said the delimiter is randomly generated. I have assumed the first part of it not random and that you don't want to enter anything.

        Try this clip. It begins at the top of a document and beginning at the first delimiter, loops through and deletes each section retaining the 2 lines above each boundary. It also deletes from the last delimiter thru the end of the document (you could change the processing for Last if that's not what you want to do).

        It will also tell you how many lines were deleted from each section.

        Have fun,
        Sheri

        H="Delete attachments"
        ^!Clearvariable %startpos%
        ^!Jump Doc_Start
        :Loop
        ^!Find "------=_NextPart_" IS
        ^!IfError Out
        ^!Set %startpos%="^$GetRowStart$:^$GetColStart$"
        ^!Jump +1
        ^!Find "------=_NextPart_" IS
        ^!IfError Last
        ^!Jump Select_Start
        ;scroll back two lines to retain name
        ^!Jump -2
        ^!SelectTo ^%startpos%
        ^!Set %count%=^$StrCount("^%NL%";"^$GetSelection$";No;No)$
        ^!InsertText (DELETED ^%count% LINES)^P
        ^!Goto Loop
        :Last
        ^!Jump Doc_End
        ^!SelectTo ^%startpos%
        ^!Set %count%=^$StrCount("^%NL%";"^$GetSelection$";No;No)$
        ^!InsertText (DELETED ^%count% LINES to End of File)^P
        :Out
        ;end
      • Chuck Anderson
        ... first part of it not random and that you don t want to enter anything. Correct - I just want to remember where it is, and I will find that spot manually.
        Message 3 of 6 , Dec 31, 2003
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@c...> wrote:
          > You said the delimiter is randomly generated. I have assumed the
          first part of it not random and that you don't want to enter anything.

          Correct - I just want to remember where it is, and I will find that
          spot manually.

          > Try this clip. It begins at the top of a document and beginning at
          the first delimiter, loops through and deletes each section retaining
          the 2 lines above each boundary.

          Very cool, 2 lines is not exactly right, I may even want to parse that
          text and pull out some info to reinsert in a new format (to leave a
          trail of what was delelted and to create a summary of the deletions a
          the end). I'll figure that part out more precisely.

          > It also deletes from the last delimiter thru the end of the document
          (you could change the processing for Last if that's not what you want
          to do).

          Yes, that would be devastating ô¿Ô¬ as it would delete the rest of
          my Inbox messages.

          >
          > It will also tell you how many lines were deleted from each section.

          I like that touch - a confirmnation of what's happening.

          > Have fun,
          > Sheri


          You both are the greatest (Sheri and Larry). You have responded so
          quickly and so helpfully that I want to respond right away (before I
          can try these out).

          I *do* want to use a wizard (for entering the delimiter string). And
          maybe I could use the wizard to paste in the name of the attachment,
          so I can leave an "att.-deleted" note in the message.

          Give me a day or two (Jan 1 doesn't count :-) to grok both of these -
          perhaps integrate elements of both - and play with them (*after I back
          up* my Inbox file).

          This is how I learn clip language the easiest, by understanding what
          youse have done. Thank you.

          (There could be a bunch of happy Netscape/Mozilla users out there once
          this is working and I let people know about it. The Mozilla based
          messenger programs do not have the ability to remove attachments from
          messages stored in the message folders - a feature many are wanting.
          I'll let you know how that goes - and I will make sure you get
          whatever credit you deserve or desire.)

          A very greatful,
          Chuck

          http://cycletourist.com - my personal home page.
        • Sheri
          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
          Message 4 of 6 , Jan 1, 2004
          • 0 Attachment
            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.,

            ^!ClearVariable %variable1%
            ^!ClearVariable %variable2%
            ..etc..

            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:

            ^$GetDocCount$
            ^$GetLineCount$
            ^$GetParaCount$
            ^$GetTextLineCount$
            ^$GetTopicCount$
            ^$StrCount$

            After highlighting "^$StrCount$", pressing Ok would:

            replace the word you typed ("count") with

            ^$StrCount("SubStr";"Str";CaseSensitive;WholeWord)$

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

            ^!Set %Index%=0
            ^!Set %LoopCount%=Howmanyloops
            ^!IfCancel End
            :LoopStart
            ^!Inc %Index%
            ^!If ^%Index%>^%LoopCount% EndLoop

            *** Do something ***

            ^!GoTo LoopStart
            :EndLoop

            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.

            http://groups.yahoo.com/group/ntb-clips/files/ClipcodeSyntax_v4.02.zip

            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

            Regards,
            Sheri
          • Chuck Anderson
            ... Same to you, as well. May this be a fortuitous and joyful year. ... You got it. (I am a web designer - very good with Php right now - C++ in my past -
            Message 5 of 6 , Jan 1, 2004
            • 0 Attachment
              --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@c...> wrote:
              > Hi Chuck, Larry, others,
              >
              > Happy New Year!!

              Same to you, as well. May this be a fortuitous and joyful 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:

              http://cycletourist.com/temp/InboxExampleReadme.txt
              http://cycletourist.com/temp/InboxExample

              Readme explains it all - hopefully. :-)

              > I use Eudora; it decodes, saves and strips attachments from messages
              before 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!)

              Thanks again,
              Chuck
            • Sheri
              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
              Message 6 of 6 , Jan 2, 2004
              • 0 Attachment
                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:

                http://groups.yahoo.com/group/ntb-clips/messages/11439?expand=1

                Regards,
                Sheri

                H="Delete attachments"
                ^!SetWordWrap Off
                ^!Continue Cursor position should be in or below email text (above attachments). If necessary Cancel and reposition the cursor.
                ^!SetHintInfo Working ...
                ^!SetScreenUpdate Off
                ^!DeleteFile "^$GetLibraryPath$delatt.txt"
                ^!Set %curdoc%=^$GetDocIndex$
                ^!Set %beginpos%=^$GetRow$:^$GetCol$
                ;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
                ^!Jump Doc_End
                ^!Jump -1
                ^!SelectTo ^%beginpos%
                ;Copy from starting point to end of message to temporary buffer
                ^!ClipBoardSave
                ^!SetClipboard ^$GetSelection$
                ^!Menu Edit/Paste New
                ^!SetClipboard ""
                ^!Select All
                ^!SetArray %attachnames%=
                ^!Set %Index%=0
                ^!Jump Doc_Start
                :Loop
                ^!Inc %Index%
                ^!Find "------=_NextPart_" TIS
                ^!IfError Out
                ^!Set %startpos%="^$GetRow$:1"
                ;Don't delete from 1st section of message (s/b text)
                ^!If ^%Index%=1 Next Else Skip_3
                ^!SelectTo 1:1
                ^!AppendToFile "^$GetLibraryPath$delatt.txt" ^$GetSelection$
                ^!SetCursor ^%startpos%
                ^!Find "^P^P" IS
                ^!SelectTo ^%startpos%
                ;Parse filename
                ^!Find "^P^Tfilename="" THS
                ;If attachment has no filename, preserve all remaining attachments in file
                ^!IfError Last
                ^!Jump Select_End
                ;Parse filename
                ^!Find "[^"]*" RS
                ^!Set %attachnames^%Index%%="^$GetSelection$"
                ^!SetCursor ^%startpos%
                ^!Jump +1
                ^!Find "------=_NextPart_" IS
                ^!IfError Last
                ^!Jump Select_Start
                ^!SelectTo ^%startpos%
                ^!Set %count%=^$StrCount("^%NL%";"^$GetSelection$";No;No)$
                ^!AppendToFile "^$GetLibraryPath$delatt.txt" *** "^%attachnames^%Index%%"(^%count% LINES DELETED)^%NL%
                ^!Jump Select_End
                ^!Goto Loop
                :Last
                ;leave last boundary in place
                ^!If ^%Index%=1 Error
                ^!Jump Doc_End
                ^!SelectTo ^%startpos%
                ^!AppendToFile "^$GetLibraryPath$delatt.txt" ^%NL%^$GetSelection$
                :Out
                ^!Close Discard
                ^!SetDocIndex ^%curdoc%
                ^!IfFileExist "^$GetLibraryPath$delatt.txt" Next Else Error
                ^!InsertSelect ^$GetFileText("^$GetLibraryPath$delatt.txt")$
                ^!SetView ^$GetRowStart$:1
                ^!Goto ClearVars
                :Error
                ^!Close Discard
                ^!SetDocIndex ^%curdoc%
                ^!SetCursor ^%beginpos%
                ^!Info Error - Cursor was not within message text or 1st boundary had no filename in expected format.
                :ClearVars
                ^!Clearvariable %attachnames%
                ^!Clearvariable %count%
                ^!Clearvariable %index%
                ^!Clearvariable %startpos%
                ^!Clearvariable %beginpos%
                ^!Clearvariable %curdoc%
                ^!ClipBoardRestore
                ;end
              Your message has been successfully submitted and would be delivered to recipients shortly.