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

Re: Selecting and deleting portions of files

Expand Messages
  • hugo_paulissen
    ... Hi Mark, This is the right list! Try this as a basic example: ^!Jump 1 ^!Find ------ S ^!Jump +1 ^!Set %startSelection%=^$GetRow$:^$GetCol$ ^!Find [.* ]
    Message 1 of 13 , Apr 22 1:57 PM
    • 0 Attachment
      >
      > How do I make the selection (in a clip)?
      >
      > I hope this is the right list for this kind of questions! :-)
      >
      > Best wishes,
      > Mark


      Hi Mark,

      This is the right list!

      Try this as a basic example:

      ^!Jump 1
      ^!Find ------ S
      ^!Jump +1
      ^!Set %startSelection%=^$GetRow$:^$GetCol$
      ^!Find "\[.*\]" R
      ^!Jump Select_END
      ^!SelectTo ^%startSelection%
      ^!Set %kriq%=^$StrReplace("------^p";"";^$GetSelection$;0;0)$
      ^!SetClipboard ^%kriq%

      The selection is based on the existence of "-------" at the beginning
      of the text to be selected, and "[uitspraak]" at the end. The
      remaining "------" is deleted, after the text is put in the variable.
      At the end the result is copied to the clipboard, but you can do
      other things as well...

      Hugo
    • Alan C.
      On Tue, 22 Apr 2003 20:31:19 +0200, Mark Partous wrote: ... For the basics of clips, gets you up to speed for the help files, there s clipclass, how I
      Message 2 of 13 , Apr 22 4:11 PM
      • 0 Attachment
        On Tue, 22 Apr 2003 20:31:19 +0200, Mark Partous wrote:
        <snip>
        >I've been looking into existing clips and in the helpfiles, but I
        >did not

        For the basics of clips, gets you up to speed for the help files, there's clipclass, how I learned it. Try
        http://www.notetab.net/
        follow mailing lists look for it.

        It's authored by Jody Adair. It used to also have a download. But I don't know how he's handling it these days. But if your'e interested, that'll give you a start.

        >find how to select parts of text-files. These are emails that are
        >being
        >appended to one file. Afterwards I used to remove manually sections

        Of your two samples texts taken from your original post, with the first of those two samples as a NoteTab document's only contents

        Then run the below clip does makes/trims/converts/transforms sample number one into sample number two.

        Sample two at that point is in the clipboard. Then if you're appending, just click another document tab and paste it into your append document along with others. Then you can begin again by pasting another from your email app, just paste it right in on top of the selected text that's still leftover in the first document tab.

        Further automation is possible ie append directly to a file (or others). But, not knowing for sure if the two words change in successive emails, I used two all caps words as the find criteria. So (while prototyping) I risked already making a mistake at this point, let alone to attempt even further automation.

        H="email_parse"
        ^!Jump 1
        ^!Find "UITSPRAAK" S
        ^!Jump LINE_END

        ^!InsertText ^%NL%
        ^!Jump -1
        ^!Set %EndSelectAt%=^$GetRow$:^$GetCol$

        ^!Jump 1
        ^!Find "OEKAZE\n\s+-+" SR
        ^!Replace "\n\s+-+" >> "^%EMPTY%" ISHR
        ^!MoveCursor -6

        ^!SelectTo ^%EndSelectAt%
        ^!SetClipboard ^$GetSelection$
        ^!Toolbar "Select All"
        ^!Replace "^$GetSelection$" >> "^%EMPTY%" ISH

        ^!Set %divider%=-----------8<-------------8<--------------
        ^!InsertText ^%divider%^%NL%
        ^!Toolbar "Paste"
        ^!InsertText ^%divider%
        ^!Toolbar "Select All"
        ^!SetClipboard ^$GetSelection$
        ;-----<end of clip------

        --
        Alan.
      • Mark Partous
        Hello hugo_paulissen, Tuesday, April 22, 2003, 10:57:34 PM, you wrote: h Try this as a basic example: That worked (this will surely be no surprise to you),
        Message 3 of 13 , Apr 23 2:06 PM
        • 0 Attachment
          Hello hugo_paulissen,

          Tuesday, April 22, 2003, 10:57:34 PM, you wrote:

          h> Try this as a basic example:


          That worked (this will surely be no surprise to you), thanks you!

          There's something that I did not explain clearly though...

          See my reply to Alan.

          --
          Best Whishes,
          Mark
          using The Bat! 1.63 Beta/7
        • Mark Partous
          Hello Alan, Wednesday, April 23, 2003, 1:11:00 AM, you wrote: AC Further automation is possible ie append directly to a file (or AC others). But, not
          Message 4 of 13 , Apr 23 2:53 PM
          • 0 Attachment
            Hello Alan,

            Wednesday, April 23, 2003, 1:11:00 AM, you wrote:

            AC> Further automation is possible ie append directly to a file (or
            AC> others). But, not knowing for sure if the two words
            AC> change in successive emails, I used two all caps words as the find
            AC> criteria. So (while prototyping) I risked already
            AC> making a mistake at this point, let alone to attempt even further automation.

            Thanks for your reply, Alan. Of course this works to select the text. Hugo
            has the advantage of knowing the Dutch language, so he was able to see that
            the first word that you used, in this case "OEKAZE" is a word that changes
            in every mail. "2003:" could be used (until the end of the year, that is).
            "UITSPRAAK" is in every mail.

            One thing that I did not seem to explain very clearly is the following fact:

            I have set up "The Bat!" in such a way that each daily mail (at least for the
            "Kriq" folder) I receive is being appended to a text file. If I new more
            about RegEx I probably could leave all of the work to The Bat!.

            That not being the case (me not knowing RegEx), I deleted what was
            superfluous manually, from time to time. That's what I'm trying to do with a
            clip now.

            So, what I am NOT doing is selecting the text in the mailer and then copy it
            in NoteTab. So, the message allready has been appended to the file in which
            the remains of the earlier mails are collected. BTW: that is why I used the
            -----------8<-------------8<-------------- line. :-)


            If I would apply your clip (as it is now) to that file, I would end up with
            the remains of only one message, or am I mistaken?

            It is possible that, at the end of my file there may be multiple inedited
            emails. Clicking several times would not be a problem, even though I guess it
            could be done by some kind of loop.

            Once again, thanks to you and Hugo, I now allready see how to select text,
            and I also will take a look at the "clipclass".


            --
            Best Whishes,
            Mark
            using The Bat! 1.63 Beta/7
          • Mark Partous
            Hello Mark, Wednesday, April 23, 2003, 11:06:20 PM, you wrote: MP thanks you! ^ Sorry, typo :-( -- Best Whishes, Mark using The Bat! 1.63 Beta/7
            Message 5 of 13 , Apr 23 2:59 PM
            • 0 Attachment
              Hello Mark,

              Wednesday, April 23, 2003, 11:06:20 PM, you wrote:

              MP> thanks you!
              ^
              Sorry, typo :-(


              --
              Best Whishes,
              Mark
              using The Bat! 1.63 Beta/7
            • hugo_paulissen
              Hi Mark, My previous version didn t cope with the fact that you need to search a file for multiple kriq-words . I added a loop and changed the first find
              Message 6 of 13 , Apr 23 3:33 PM
              • 0 Attachment
                Hi Mark,

                My previous version didn't cope with the fact that you need to search
                a file for multiple "kriq-words". I added a loop and changed the
                first find construct (into a regular expression) since it occured to
                me that you may have different lenghts of dashes, and they may occur
                elsewhere as well... Tested with a file that had several copies of
                your original text.


                ^!Jump 1
                ^!Set %output%=""
                :LOOP
                ^!Find "^-+\n.+\n-+$" RS
                ^!IfError END
                ^!Jump -1
                ^!Set %startSelection%=^$GetRow$:^$GetCol$
                ^!Find "\[.*\]" RS
                ^!Jump Select_END
                ^!SelectTo ^%startSelection%
                ^!Set %kriq%=^$StrReplace("------^p";"";^$GetSelection$;0;0)$
                :OUTPUT
                ^!Jump Select_END
                ^!Set %output%=^%output%^%NL%^%NL%=====================^%NL%^%NL%^%
                kriq%
                ^!GoTo LOOP
                :END
                ;I jsut delete the old file here; adapt to suit your own needs...
                ^!Menu Edit/Clear All
                ^%output%
              • Mark Partous
                Hello hugo_paulissen, Thursday, April 24, 2003, 12:33:21 AM, you wrote: h My previous version didn t cope with the fact that you need to search h a file for
                Message 7 of 13 , Apr 24 2:01 AM
                • 0 Attachment
                  Hello hugo_paulissen,

                  Thursday, April 24, 2003, 12:33:21 AM, you wrote:

                  h> My previous version didn't cope with the fact that you need to search
                  h> a file for multiple "kriq-words". I added a loop and changed the
                  h> first find construct (into a regular expression) since it occured to
                  h> me that you may have different lenghts of dashes, and they may occur
                  h> elsewhere as well... Tested with a file that had several copies of
                  h> your original text.

                  When I try this one out, the only thing I get is an empty screen...
                  I tried to turn out ClipMate, but that did not change anything.

                  Did I do something wrong?

                  --
                  Best Whishes,
                  Mark
                  using The Bat! 1.63 Beta/7
                • Alan C.
                  ... It appear also that pattern in every mail thus ... OEKAZE ... or -- ---- 7word ... or ... hi there -- ---- built regex accomodates those, goes for the
                  Message 8 of 13 , Apr 25 3:35 AM
                  • 0 Attachment
                    On Wed, 23 Apr 2003 23:53:40 +0200, Mark Partous wrote:

                    >in every mail. "2003:" could be used (until the end of the year,
                    >that is).
                    >"UITSPRAAK" is in every mail.

                    It appear also that pattern in every mail thus

                    ------
                    OEKAZE
                    ------

                    or

                    -- ----
                    7word
                    ---- --

                    or

                    ---- --
                    hi there
                    -- ----

                    built regex accomodates those, goes for the general pattern, not the minor variations.

                    Now, mind you, I'm not a regex expert. But it works pretty good. And, now I'll go back to my Perl regex as I find them easier.

                    >If I would apply your clip (as it is now) to that file, I would end
                    >up with
                    >the remains of only one message, or am I mistaken?

                    you are correct. I tried it. all multiples gone, finish with only 1 parsed message.

                    >It is possible that, at the end of my file there may be multiple
                    >inedited
                    >emails.

                    Well, (the clip) I chunked it down, put some of it in a sub routine clip.

                    I ran the new clip(s) on three (multiples), it completed in about a second and a half on my 'puter. The multiples sample I used have a blank line between each individual mail to be parsed.

                    I had fun playing with it. It work good here on multiple unedited (blank line between each unedited).

                    Holler (not in Dutch though if you want a reply from me--unless you want to also teach a bit of it at a time that is) if you have any question or further minor tweaking. Two clips follow (one parent and its child clip).

                    H="parse_multiple"
                    ; AC 4-25-2003
                    ; init or initial stuff
                    ^!SetScreenUpdate OFF
                    ^!Set %DocIndex%=^$GetDocIndex$
                    ^!SetWordWrap OFF
                    ^!Open ^$GetTempFile$
                    ^!Set %TmpDocIndex%=^$GetDocIndex$
                    ^!SetWordWrap OFF
                    ^!SetDocIndex ^%DocIndex%
                    ^!Set %divider%=-----------8<-------------8<--------------
                    ^!Set %init_row%=^$GetRow$
                    ^!Jump LINE_START
                    ^!ClearVariable %built_regex%

                    ; build a tagged match regex. This regex finds a 3 line pattern
                    ; containing a word. This regex's tagged match reinserts the word
                    ; minus the word's wrapper (the other 2 surrounding lines).

                    ; 1st of header (1st of 3 found lines)
                    ^!Append %built_regex%=^[\s\s\s]+-\w+\n

                    ; 2nd of 3 found lines (contains the word(s))
                    ^!Append %built_regex%=\s+{\W+\s*\W*}\n

                    ; 3rd of 3 found lines
                    ^!Append %built_regex%=\s+-\w+\n

                    :post_init_stuff
                    ^!Find "-----8<-----" S
                    ^!IfError my_aft_stuff
                    ^!Set %sel_point1%=^$GetRow$:1
                    ^!Find "-----8<-----" S
                    ^!IfError my_aft_stuff
                    ^!Jump LINE_END
                    ^!Set %sel_point2%=^$GetRow$:^$GetCol$
                    ^!SetCursor ^%sel_point1%
                    ^!SelectTo ^%sel_point2%
                    ^!SetClipboard ^$GetSelection$

                    ; sub routine clip
                    ^!Clip parse_ea

                    ^!Toolbar "Paste"
                    ^!Goto post_init_stuff

                    :my_aft_stuff
                    ^!Set %cleanup%=^$GetShort("^$GetTmpPath$")$
                    ^!SetDocIndex ^%TmpDocIndex%
                    ^!Close DISCARD
                    ^!SetDocIndex ^%DocIndex%
                    ^!SetCursor ^%init_row%:1
                    ^!ClearVariable %built_regex%
                    ^!DeleteFile ^%cleanup%efo*

                    H="_parse_ea"
                    ; Welcome, I'm parse_ea sub clip. I parse 1 at a time
                    ^!SetDocIndex ^%TmpDocIndex%
                    ^!Toolbar "Paste"
                    ^!Jump 1

                    ^!Find "UITSPRAAK" S
                    ^!Jump LINE_END
                    ^!InsertText ^%NL%^%divider%^%NL%
                    ^!Jump -1
                    ^!Set %EndSelectAt%=^$GetRow$:^$GetCol$
                    ^!Jump 1

                    ; who would want to eyeball this entire regex (not me)
                    ; "^[\s\s\s]+-\w+\n\s+{\W+\s*\W*}\n\s+-\w+\n" >> "\1\n\n" SR

                    ; formerly built tagged match regex
                    ^!Replace "^%built_regex%" >> "^%divider%^%NL%\1\n\n" SR

                    ^!Jump -3
                    ^!SelectTo ^%EndSelectAt%
                    ^!SetClipboard ^$GetSelection$
                    ^!Toolbar "Select All"
                    ^!Replace "^$GetSelection$" >> "^%EMPTY%" ISH
                    ^!SetDocIndex ^%DocIndex%
                    ;-----<end of clips<

                    --
                    Alan.
                  • hugo_paulissen
                    Alan, Mark, Apparently the reason why my clip didn t work had to do with the original mail being treated by Yahoo/the web. I have a slightly different clip
                    Message 9 of 13 , Apr 25 4:19 AM
                    • 0 Attachment
                      Alan, Mark,

                      Apparently the reason why my clip didn't work had to do with the
                      original mail being treated by Yahoo/the web. I have a slightly
                      different clip that should do what Mark wants it to do. (changed the
                      regular expressions and searches a little further now, since the text
                      Mark provided us with now was different from the first post..

                      Hugo

                      Look out for long lines (like the one with ===etc)

                      ;^!SetDebug ON
                      ^!Jump 1
                      ^!Set %output%=""
                      :LOOP
                      ^!Find "\s+-+\n.+\n\s+-+" RS
                      ^!IfError END
                      ^!Jump -1
                      ^!Set %startSelection%=^$GetRow$:^$GetCol$
                      ^!Find "^-+$" RS
                      ^!Jump Select_END
                      ^!SelectTo ^%startSelection%
                      ^!Set %kriq%=^$StrReplace("-";"";^$GetSelection$;0;0)$
                      :OUTPUT
                      ^!Jump Select_END
                      ^!Set %output%=^%output%^%NL%^%NL%=====================^%NL%^%NL%^%
                      kriq%
                      ^!GoTo LOOP
                      :END
                      ;I just delete the old file here; adapt to suit your own needs...
                      ^!Menu Edit/Clear All
                      ^%output%
                    • Alan C.
                      On Fri, 25 Apr 2003 11:19:54 -0000, hugo_paulissen wrote: ... Hugo your clip is faster than mine. And I d forgotton about the possibility of appending
                      Message 10 of 13 , Apr 25 3:10 PM
                      • 0 Attachment
                        On Fri, 25 Apr 2003 11:19:54 -0000, hugo_paulissen wrote:
                        <snip>
                        >I have a slightly
                        >different clip that should do what Mark wants it to do. (changed the
                        >regular expressions and searches a little further now, since the
                        >text

                        Hugo your clip is faster than mine. And I'd forgotton about the possibility of appending each onto a variable which you essentially do except you use set to do it instead of using append.

                        Mine lengthy regex probably cover for more little potential variances (if that's needed, it might not be needed)

                        To any list members, Here's a query that I have: I don't reverse select (from a larger line number, backwards, up towards top of doc) in my clips because I had seen somewhere in the past something to the effect of some NoteTab flavors do not support it but only the Pro version is it supported.

                        --
                        Thanks. Alan.
                      • Mark Partous
                        Hello hugo_paulissen, Friday, April 25, 2003, 1:19:54 PM, you wrote: h Alan, Mark, h Apparently the reason why my clip didn t work had to do with the h
                        Message 11 of 13 , May 1, 2003
                        • 0 Attachment
                          Hello hugo_paulissen,

                          Friday, April 25, 2003, 1:19:54 PM, you wrote:

                          h> Alan, Mark,

                          h> Apparently the reason why my clip didn't work had to do with the
                          h> original mail being treated by Yahoo/the web. I have a slightly
                          h> different clip that should do what Mark wants it to do. (changed the
                          h> regular expressions and searches a little further now, since the text
                          h> Mark provided us with now was different from the first post..

                          h> Hugo

                          h> Look out for long lines (like the one with ===etc)

                          h> ;^!SetDebug ON
                          h> ^!Jump 1
                          h> ^!Set %output%=""
                          h> :LOOP
                          h> ^!Find "\s+-+\n.+\n\s+-+" RS
                          h> ^!IfError END
                          h> ^!Jump -1
                          h> ^!Set %startSelection%=^$GetRow$:^$GetCol$
                          h> ^!Find "^-+$" RS
                          h> ^!Jump Select_END
                          h> ^!SelectTo ^%startSelection%
                          h> ^!Set %kriq%=^$StrReplace("-";"";^$GetSelection$;0;0)$
                          h> :OUTPUT
                          h> ^!Jump Select_END
                          h> ^!Set %output%=^%output%^%NL%^%NL%=====================^%NL%^%NL%^%kriq%
                          h> ^!GoTo LOOP
                          h> :END
                          h> ;I just delete the old file here; adapt to suit your own needs...
                          h> ^!Menu Edit/Clear All
                          h> ^%output%


                          I still had a problem with this. As I explained before my setup was the
                          following:

                          The Bat! receives the message and appends it to a file named kriq.txt.
                          Then I manually removed what had to be removed. New messages were being
                          appended on a (work)daily basis.

                          When I apply the above clip to Kriq.txt I am stuck with the result of the
                          transformation. That is: only that part of Kriq.txt (at the end of the file)
                          that contained the newly appended messages was being treated and "remembered"
                          by this clip. All the earlier results simply were not being copied, and thus
                          would have been lost forever.

                          This seems the easiest way out to me: I have changed the last line of code

                          ^%output%

                          into

                          ^!AppendToFile "D:\Program Files\The Bat\MAIL\Kriqs.txt" ^%output%

                          So now I end up with an empty Kriq.txt, ready to receive the next messages,
                          and a Kriqs.txt containing (and adding up) all the earlier results.
                          It works!

                          Thanks again for your help.

                          --
                          Best Whishes,
                          Mark
                          using The Bat! 1.63 Beta/7
                        • hugo_paulissen
                          Hi Mark, ... the ... [snip] ... of code ... Great you found out how to place something at the end of the current file (the clip showed that you had to do
                          Message 12 of 13 , May 2, 2003
                          • 0 Attachment
                            Hi Mark,

                            > I still had a problem with this. As I explained before my setup was
                            the
                            > following:
                            >
                            [snip]
                            > This seems the easiest way out to me: I have changed the last line
                            of code
                            >
                            > ^%output%
                            >
                            > into
                            >
                            > ^!AppendToFile "D:\Program Files\The Bat\MAIL\Kriqs.txt" ^%output%
                            >

                            Great you found out how to place something at the end of the current
                            file (the clip showed that you had to do something with the last
                            line ;-).

                            Hugo
                          Your message has been successfully submitted and would be delivered to recipients shortly.