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

Re: Clipboard boilerplate for cn_le

Expand Messages
  • cn_le
    Hi loro, Thanks very much for helping me out with this. Unfortunately, even with your very detailed instructions and with the small fix you noted, I can t
    Message 1 of 24 , Apr 19, 2010
    • 0 Attachment
      Hi loro,

      Thanks very much for helping me out with this. Unfortunately, even with your very detailed instructions and with the small fix you noted, I can't seem to get it to work.

      I really like Notetab's pre-made clipbook libraries but until Notetab can make this running clipboard function a standard feature, I think I'm going to use a different text editor for my regular use. Nonetheless, thank you again for your kind assistance.



      --- In ntb-clips@yahoogroups.com, loro <tabbie@...> wrote:
      >
      > Hi!
      >
      > cn_le asked about something like this on the Basic list and since I
      > happened to have an old clip that just needed a little cleaning up I
      > thought I'd post it... Turned out the cleaning up took 4 hours. More
      > about that below.
      >
      > Copy between the lines. Create a new library by right-clicking over
      > the combo box on top of the clipbook, then right-click in the blank
      > clipbook window and choose "Add from Clipboard". This will result in
      > 4 lines. The first one turns the clipboard watching on and off. The
      > second is for clearing all collected snips. The third one is grayed
      > out and can't be clicked. That's the clip that makes something happen
      > when you copy text to the clipboard. The fourth, the red one, is just
      > a delimiter, but it's needed for the Clear clip to work correctly, so
      > don't delete it. The snips that are saved from the clipbook will show
      > up below it. Everything below this line will be deleted when you run
      > the Clear clip. There's one long line that will probably be broken by
      > email. You have to join it to one line again. It's marked out with comments.
      >
      > -----------------------------------------------------
      > H="Status On/Off"
      >
      > ^!Set %watch_clipboard%=^?{Watch clipboard==ON^=1|OFF^=0}
      >
      > H="Clear collected text"
      > ^!Set %ww%=^$IsWordWrap$
      > ^!Set %curr_doc%=^$GetDocIndex$
      > ^!SetWordWrap off
      > ^!SetScreenUpdate off
      >
      > ^!Open "^$GetLibraryPath$^$GetLibraryName$.clb"
      > ^!Jump text_start
      > ^!Find "^%sc%Text collected from clipboard""
      > ^!Jump select_end
      > ^!Set %deltxt%=^$GetRow$:^$GetCol$
      > ^!Jump text_end
      > ^!SelectTo ^%deltxt%
      > ^!Menu Edit/Delete
      > ^!Save
      > ^!Export "^##" ANSI
      > ^!Close
      >
      >
      > ^!SetDocIndex ^%curr_doc%
      > ^!If ^%ww%=1 next else end
      > ^!SetWordWrap on
      > ^!ReloadLibrary
      >
      > H="_OnClipboardChange"
      >
      > ^!IfFalse ^%watch_clipboard% end else next
      > ; Long line follows
      > ^!AppendToFile "^$GetLibraryPath$^$GetLibraryName$.clb"
      > ^%nl%^%nl%h="^$StrReplace("^p";"^%space%";"^$StrCopy("^$GetClipboard$";1;50)$";false;false)$"^%nl%^$GetClipboard$^%nl%
      > ; End long line
      > ^!ReloadLibrary
      >
      > H=";Text collected from clipboard"
      > ------------------------------------------------------------------
      >
      > Now to the 4 hour cleanup. First the clip worked. Then it didn't.
      > After some fiddling it started to work again and then it stopped
      > again. That is, it stopped to show the copied text in the clipbook
      > but when I opened the library as a document the text was there and it
      > looked perfectly alright. Drove me nuts. After three hours or so I
      > discovered that when viewed in the clip editor the copied text was
      > inserted under the red heading, as content!
      >
      > At last I opened the clb in another editor and it showed that some
      > line endings were windows CR/LF and some were LF and that's what made
      > Notetab screw up as it turned out! I have Notetab set to save with
      > Unix line endings but the clipbook editor of course uses Windows
      > ones. Since the clip opens the library as a document and saves it
      > again I ended up with line ending clutter. Hence the ^!Export in the
      > clip. That fixed it (touch wood!). I learnt something from this, so I
      > thought I should tell the gruesome story and maybe save someone else
      > from pulling their hair out as I did.
      >
      > I'll direct cn_le here shortly.
      >
      > Lotta
      >
    • loro
      ... Wee! :-) ... What did you find in the help file? I don t have a space. Do you mean between the two below? ...^%nl%^%nl%h= ^$StrReplace... Lotta
      Message 2 of 24 , Apr 19, 2010
      • 0 Attachment
        Larry wrote:
        >Found the problem!

        Wee! :-)

        >I needed a space on the ^!AppendToFile line between the second " and the
        >first ^%NL%.
        >
        >I added a debug and the clip was "working", except for the append part. It
        >was not until I changed to to paste to an OTL then a txt file that I
        >reviewed the help file and happened to notice the missing space. I cleaned
        >up that long line just a little too much. :-(

        What did you find in the help file? I don't have a space. Do you mean
        between the two below?
        ...^%nl%^%nl%h="^$StrReplace...

        Lotta
      • loro
        ... Maybe it s the long line. ... Well, there can t be pre-written clips for everything and I think the possibility to create almost anything, yourself or with
        Message 3 of 24 , Apr 19, 2010
        • 0 Attachment
          cn_le wrote:
          >Thanks very much for helping me out with this. Unfortunately, even
          >with your very detailed instructions and with the small fix you
          >noted, I can't seem to get it to work.

          Maybe it's the long line.

          >I really like Notetab's pre-made clipbook libraries but until
          >Notetab can make this running clipboard function a standard feature,
          >I think I'm going to use a different text editor for my regular
          >use. Nonetheless, thank you again for your kind assistance.

          Well, there can't be pre-written clips for everything and I think the
          possibility to create almost anything, yourself or with a little help
          from your friends, is worth more. Premade features seldom fit my needs anyway.

          If you don't mind, I'll send the library privately as file. I'm just
          curios to know if this thing is hexed.

          Lotta
        • diodeom
          ... Lotta, I suspect that some (all?) Vista and 7 users with typical NTB installs might have an issue with where newly-made custom libraries default to:
          Message 4 of 24 , Apr 19, 2010
          • 0 Attachment
            loro <tabbie@...> wrote:
            >
            > <snip>
            > That fixed it (touch wood!). I learnt something from this,
            > so I thought I should tell the gruesome story and maybe
            > save someone else from pulling their hair out as I did.
            >

            Lotta,

            I suspect that some (all?) Vista and 7 users with typical NTB installs might have an issue with where newly-made custom libraries default to: C:\Users\=>UserName<=\AppData\Roaming\NoteTab Pro\Libraries\, a location which is not read by ^$GetLibraryPath$. When the actual path is hard-coded, your handy lib performs as intended -- at least for me. Thank you!

            Dio
          • loro
            ... Duh. I ve always used the ini option myself, but I ve always thought ^$GetLibraryPath$ and related functions worked either way you had it set up. What a
            Message 5 of 24 , Apr 19, 2010
            • 0 Attachment
              diodeom wrote:
              >I suspect that some (all?) Vista and 7 users with typical NTB
              >installs might have an issue with where newly-made custom libraries
              >default to: C:\Users\=>UserName<=\AppData\Roaming\NoteTab
              >Pro\Libraries\, a location which is not read by ^$GetLibraryPath$.
              >When the actual path is hard-coded, your handy lib performs as
              >intended -- at least for me. Thank you!

              Duh. I've always used the ini option myself, but I've always thought
              ^$GetLibraryPath$ and related functions worked either way you had it
              set up. What a bummer. Thanks for telling me. But how to handle that
              if you want to share clips?

              Nice if you can find use for the clip. It's set up to my own liking,
              so you may want to change some things. The clip titles for the saved
              snips are shortened to 50 characters and line breaks are replaced
              with a space character (in the title only). The latter or something
              similar is sort of needed or the titles could become very short.
              Maybe it would be a good idea to replace tabs too.

              Lotta
            • Larry Hamilton
              ... In my email, it breaks here, after ...clb ^!AppendToFile ^$GetLibraryPath$^$ GetLibraryName$.clb ^%nl%^%nl%h= ^$StrReplace When I took out the
              Message 6 of 24 , Apr 19, 2010
              • 0 Attachment
                On Mon, Apr 19, 2010 at 2:26 PM, loro <tabbie@...> wrote:

                > Larry wrote:
                > >Found the problem!
                >
                > Wee! :-)
                >
                > >I needed a space on the ^!AppendToFile line between the second " and the
                > >first ^%NL%.
                > >
                > >I added a debug and the clip was "working", except for the append part. It
                > >was not until I changed to to paste to an OTL then a txt file that I
                > >reviewed the help file and happened to notice the missing space. I cleaned
                > >up that long line just a little too much. :-(
                >
                > What did you find in the help file? I don't have a space. Do you mean
                > between the two below?
                > ...^%nl%^%nl%h="^$StrReplace...
                >
                > Lotta
                >

                In my email, it breaks here, after '...clb"'

                ^!AppendToFile "^$GetLibraryPath$^$
                GetLibraryName$.clb"
                ^%nl%^%nl%h="^$StrReplace <snip>

                When I took out the line break it did not leave a space after '...clb"' and
                before ^%nl%.

                ~ Larry


                [Non-text portions of this message have been removed]
              • diodeom
                ... Actually, either of these seems to work just fine: ^$GetLibraryPath(^$GetLibraryName$)$ ^$GetLibraryUserPath$
                Message 7 of 24 , Apr 19, 2010
                • 0 Attachment
                  loro <tabbie@...> wrote:
                  >
                  > Duh. I've always used the ini option myself, but I've always thought
                  > ^$GetLibraryPath$ and related functions worked either way you had it
                  > set up. What a bummer. Thanks for telling me. But how to handle that
                  > if you want to share clips?
                  >

                  Actually, either of these seems to work just fine:

                  ^$GetLibraryPath(^$GetLibraryName$)$
                  ^$GetLibraryUserPath$
                • diodeom
                  ... I see by now that for me to call your concept handy was a terrible understatement. I m at the point of asking myself: why would I still want to employ
                  Message 8 of 24 , Apr 19, 2010
                  • 0 Attachment
                    loro <tabbie@...> wrote:
                    >
                    > Nice if you can find use for the clip. It's set up to my own
                    > liking, so you may want to change some things. The clip titles
                    > for the saved snips are shortened to 50 characters and line
                    > breaks are replaced with a space character (in the title only).
                    > The latter or something similar is sort of needed or the titles
                    > could become very short. Maybe it would be a good idea to
                    > replace tabs too.
                    >
                    > Lotta

                    I see by now that for me to call your concept "handy" was a terrible understatement. I'm at the point of asking myself: why would I still want to employ another app for the majority of my manual text capturing tasks, when in your brilliantly simple "organizing clip/pasteboard" copied snippets become conveniently identifiable, paste-able, free of any formatting gunk and, most importantly, directly scriptable -- all right in my favorite text processor?
                  • loro
                    ... Got it! I misunderstood. Lotta
                    Message 9 of 24 , Apr 19, 2010
                    • 0 Attachment
                      Larry Hamilton wrote:
                      >loro <tabbie@...> wrote:
                      > > What did you find in the help file? I don't have a space. Do you mean
                      > > between the two below?
                      >
                      >In my email, it breaks here, after '...clb"'
                      >
                      >^!AppendToFile "^$GetLibraryPath$^$
                      >GetLibraryName$.clb"
                      >^%nl%^%nl%h="^$StrReplace <snip>

                      Got it! I misunderstood.

                      Lotta
                    • loro
                      ... Brilliant is a slight overstatement, but thank you kindly, sir! :-) Since you like it you may want a clip I removed when I posted it before. It pasts all
                      Message 10 of 24 , Apr 19, 2010
                      • 0 Attachment
                        diodeom wrote:
                        >I see by now that for me to call your concept "handy" was a terrible
                        >understatement. I'm at the point of asking myself: why would I still
                        >want to employ another app for the majority of my manual text
                        >capturing tasks, when in your brilliantly simple "organizing
                        >clip/pasteboard" copied snippets become conveniently identifiable,
                        >paste-able, free of any formatting gunk and, most importantly,
                        >directly scriptable -- all right in my favorite text processor?

                        "Brilliant" is a slight overstatement, but thank you kindly, sir! :-)
                        Since you like it you may want a clip I removed when I posted it
                        before. It pasts all collected snips in a new document. I find it
                        easier to remove unwanted snip-clips and then paste it all than the
                        other way around.

                        Thanks for the info about what library path functions that work.
                        ^$GetLibraryPath(^$GetLibraryName$)$ may be the best one since tha
                        also works in 4.95. I've installed a Light w/o ini now. Probably good
                        to test before sharing.

                        Here goes. 3 longish lines.
                        ---------------------------
                        h="Paste All"

                        ^!Set %ww%=^$IsWordWrap$
                        ^!Set %snips%=^%empty%
                        ^!SetWordWrap off
                        ^!SetScreenUpdate off

                        ; Long line
                        ^!Open "^$GetLibraryPath(^$GetLibraryName$)$^$GetLibraryName$.clb"
                        ; End long line
                        ^!Jump text_start
                        ^!Find "^%sc%Text collected from clipboard""

                        :loop
                        ^!Jump select_end
                        ^!Find "h="" SI
                        ^!IfError do
                        ^!Jump select_end
                        ^!Set %start_pos%=^$GetRow$:^$GetCol$
                        ^!Find """
                        ^!Jump select_start
                        ^!SelectTo ^%start_pos%
                        ^!Set %this%=^$GetSelection$¤
                        ^!Append %snips%=^%this%
                        ^!Goto loop

                        :do
                        ^!Set %cntr%=0
                        ^!SetListDelimiter ¤
                        ; Long line
                        ^!SetArray %snips%=^$StrDelete("^%snips%";^$StrSize("^%snips%")$;1)$
                        ; End long line
                        ^!Close
                        ^!Menu File/new
                        :paste-loop
                        ^!Inc %cntr%
                        ^!Clip "^%snips^%cntr%%"
                        ; Long line
                        ^!InsertText --------------------------------------^p
                        ; End long line
                        ^!If ^%cntr%=^%snips0% fini
                        ^!Goto paste-loop

                        :fini
                        ^!If ^%ww%=1 next else end
                        ^!SetWordWrap on
                        ---------------------------

                        Lotta
                      • hsavage
                        ... All, Let s not forget ^$GetLibraryFileName$, it supplies the complete path and filename of the library loaded in the clip editor.
                        Message 11 of 24 , Apr 19, 2010
                        • 0 Attachment
                          diodeom wrote:
                          > loro <tabbie@...> wrote:
                          >> Duh. I've always used the ini option myself, but I've always thought
                          >> ^$GetLibraryPath$ and related functions worked either way you had it
                          >> set up. What a bummer. Thanks for telling me. But how to handle that
                          >> if you want to share clips?
                          >>
                          >
                          > Actually, either of these seems to work just fine:
                          >
                          > ^$GetLibraryPath(^$GetLibraryName$)$
                          > ^$GetLibraryUserPath$

                          All,

                          Let's not forget ^$GetLibraryFileName$, it supplies the complete path
                          and filename of the library loaded in the clip editor.

                          ·············································
                          ºvº SL_day# 110 - created 2010.04.20_00.46.36

                          I just want revenge. Is that so wrong?

                          € hrs € hsavage € pobox € com
                        • diodeom
                          ... Thanks! (It would ve been a bit easier to forget if I ve had a clue it existed. :)
                          Message 12 of 24 , Apr 20, 2010
                          • 0 Attachment
                            hsavage <hsavage@...> wrote:
                            >
                            > All,
                            >
                            > Let's not forget ^$GetLibraryFileName$, it supplies the
                            > complete path and filename of the library loaded in the
                            > clip editor.
                            >

                            Thanks!
                            (It would've been a bit easier to forget if I've had a clue it existed. :)
                          • diodeom
                            ... Here s yet another approach to agglomerate all processed clippings: H= Paste all ^!Menu File/New ^!InsertFile ^$GetLibraryFileName$ ^!Replace
                            Message 13 of 24 , Apr 20, 2010
                            • 0 Attachment
                              loro <tabbie@...> wrote:
                              >
                              > Since you like it you may want a clip I removed when I posted it
                              > before. It pasts all collected snips in a new document. I find it
                              > easier to remove unwanted snip-clips and then paste it all than the
                              > other way around.
                              >

                              Here's yet another approach to agglomerate all processed clippings:

                              H="Paste all"
                              ^!Menu File/New
                              ^!InsertFile ^$GetLibraryFileName$
                              ^!Replace "(?s).+?^H\=";Text.+?\R+" >> "" WRS
                              ^!Replace "(\R)?\K(?(1)\R+)^H\=.++\R+" >> "---------------\r\n" WARS

                              But for my needs, to selectively remove from the library either already distributed clips or any junk ones, I found this (working-for-me rough draft) more practical:

                              H="Remove selected clips"
                              ^!Open "^$GetLibraryFileName$" /J=-1
                              ^!Set %bot%=^$GetRow$:^$GetCol$
                              ^!Find "^H\=";Text.++\R\K" WRS
                              ^!SelectTo ^%bot%
                              ^!SetListDelimiter |
                              ^!Set %del%=^$GetDocMatchAll("^H\=\"\K(.+?)(?=\"$)")$
                              ^!SetArray %del%=^?{(T=A;H=50)=^%del%}
                              ^!Set %n%=0
                              :Del
                              ^!Inc %n%
                              ^!If ^%n%>^%del0% Done
                              ;Long line start
                              ^!Replace "\R\R\K\R*^H\=\"\Q^%del^%n%%\E\"$(?s).+?(?=(^H\=\"|\R*\Z))" >> "" WRS
                              ;Long line end
                              ^!Goto Del
                              :Done
                              ^!Replace "\R+\Z" >> "\r\n" WRS
                              ^!Close Save
                              ^!ClearVariable %bot%
                              ^!ClearVariable %del%
                              ^!ClearVariable %n%

                              A word of caution: the patterns here look for capitalized "H" for headers, not lowercase like in your original OnClipboardChange clip.

                              And I omitted provisions for headers not being unique. I'd opt for not permitting duplicate names right when clippings are created and processed (in my case quite extensively). Also, some executable clip code in headers can mess things up (I'm speaking from regretable experience :) -- unless similarly addressed beforehand.
                            • loro
                              ... Yeah, no doubt regex is shorter, apart from the time it takes to learn it. I procrastinate. ... Neat! Thank you. What does the J switch do though? I don t
                              Message 14 of 24 , Apr 20, 2010
                              • 0 Attachment
                                diodeom wrote:
                                >Here's yet another approach to agglomerate all processed clippings:

                                Yeah, no doubt regex is shorter, apart from the time it takes to
                                learn it. I procrastinate.

                                >But for my needs, to selectively remove from the library either
                                >already distributed clips or any junk ones, I found this
                                >(working-for-me rough draft) more practical:
                                >
                                >H="Remove selected clips"
                                >^!Open "^$GetLibraryFileName$" /J=-1

                                Neat! Thank you. What does the J switch do though? I don't see it in Help.

                                >A word of caution: the patterns here look for capitalized "H" for
                                >headers, not lowercase like in your original OnClipboardChange clip.

                                OK. I think Notetab converts to uppercase H even if you type/enter
                                lowercase h. It's a little mysterious, because it doesn't happen
                                right away and restarting Notetab doesn't make it happen either. Yet
                                all my clipboard snips from yesterday now use uppercase H but the new
                                ones use lower case. Go figure. I'll change my clip to use uppercase.

                                >And I omitted provisions for headers not being unique. I'd opt for
                                >not permitting duplicate names right when clippings are created and
                                >processed (in my case quite extensively). Also, some executable clip
                                >code in headers can mess things up (I'm speaking from regretable
                                >experience :) -- unless similarly addressed beforehand.

                                Yesterday I realized that my OnClipBoardChange clip sometimes screws
                                up when the copied text contains quotes (but only sometimes) and you
                                end up with a broken heading like so
                                H="heading
                                "
                                which messes up the following snips. A little odd. Maybe it was
                                something else than quotes that made it happened even if I blamed the
                                quotes at the time. Haven't looked into it yet.

                                Lotta
                              • diodeom
                                ... Oh?! You would not believe, Lotta, how totally with you I am on procrastination as a general principle :), yet still I m obliged to comment: Wow{3,},
                                Message 15 of 24 , Apr 20, 2010
                                • 0 Attachment
                                  loro <tabbie@...> wrote:
                                  >
                                  > Yeah, no doubt regex is shorter, apart from the time it takes
                                  > to learn it. I procrastinate.
                                  >

                                  Oh?!

                                  <rant>You would not believe, Lotta, how totally with you I am on procrastination as a general principle :), yet still I'm obliged to comment:

                                  Wow{3,}, what a blasphemous and discouraging statement from such an exemplary, appreciated and committed tabbie! :) Have you given any consideration to how devastating your words might be to impressionable minds of newbies like myself? I mean, really, have you? It's almost like saying that computers could be somewhat useful if it weren't so problematic to locate the right keys on a keyboard, you know, when needed. :)

                                  To me, once I succeed in keying in some cryptic characters that just somehow seem to pinpoint what I'm after (I'd readily confess here that, at least from my perspective, it's much more fun to write this crap than to read it :), I get to sit back, embrace my natural laziness, and leave sweating to the eager Eric's brainchild (as awful as it might sound out of context) and all the other great brainchildren of others it climbed upon. I consider PCRE as one of NoteTab's most prominent, desirable features, which permits all sorts of folks, myself included, no matter how little adept in scripting, to gradually and conveniently utilize many blessings of the text-processing automation on an as-needed basis, without (or prior to) having to (often needlessly) dive into any fully-pledged and potentially head-scratching programming in Perl or its competitors -- for most (not necessarily trivial) textual manipulation tasks at hand.

                                  It doesn't go without saying that in regard to my cherished-by-now regex I am, like probably many other grateful recent abusers of this forum, seriously indebted to some persistent silverwoman -- for her clearly outlined examples and repetitively cited sources of easily comprehensible regex wisdom.</rant>

                                  > What does the J switch do though? I don't see it in Help.
                                  >

                                  It's under ^!Open "FileName" [/R] [/J=nnn] in Document Management section:

                                  "(...) the /J= switch can be used to place the cursor at a specific line number when it is opened. If /J=-1, the cursor will be placed at the beginning of the last line."

                                  After utilizing this, I thought there was no reason to advance the cursor to the end of the line/paragraph, because your clip-making clip assures newline at the very end anyway.

                                  > OK. I think Notetab converts to uppercase H even if you type/
                                  > enter lowercase h. It's a little mysterious, because it
                                  > doesn't happen right away and restarting Notetab doesn't make
                                  > it happen either. Yet all my clipboard snips from yesterday
                                  > now use uppercase H but the new ones use lower case. Go
                                  > figure. I'll change my clip to use uppercase.
                                  >

                                  You see, I've stumbled upon the same issues you're describing when attempting to remove some freshly made clippings, so I opted for explicit prior capitalization, though there are obvious alternatives (e.g. making the search case-insensitive).

                                  > Yesterday I realized that my OnClipBoardChange clip sometimes
                                  > screws up when the copied text contains quotes (but only
                                  > sometimes) and you end up with a broken heading like so
                                  > H="heading
                                  > "
                                  > which messes up the following snips. A little odd. Maybe it
                                  > was something else than quotes that made it happened even if
                                  > I blamed the quotes at the time. Haven't looked into it yet.
                                  >
                                  > Lotta
                                  >

                                  Please do share if you find out more. I'm still somewhat timid when it comes to playing with an active library, but your (new to me) idea has opened some very interesting possibilities, as I was able to put it into some immediate "useful use" with no unresolvable glitches so far.

                                  Thank you.
                                • loro
                                  ... Oh phooey! :-P I m sure you are a more experienced scripter than I am. I ll always be a klutz. I didn t mean what I said the way you took it, I think.
                                  Message 16 of 24 , Apr 20, 2010
                                  • 0 Attachment
                                    diodeom wrote:
                                    >loro <tabbie@...> wrote:
                                    > > Yeah, no doubt regex is shorter, apart from the time it takes
                                    > > to learn it. I procrastinate.
                                    >
                                    ><rant>You would not believe, Lotta, how totally with you I am on
                                    >procrastination as a general principle :), yet still I'm obliged to comment:
                                    >
                                    >Wow{3,}, what a blasphemous and discouraging statement from such an
                                    >exemplary, appreciated and committed tabbie! :) Have you given any
                                    >consideration to how devastating your words might be to
                                    >impressionable minds of newbies like myself? I mean, really, have
                                    >you? It's almost like saying that computers could be somewhat useful
                                    >if it weren't so problematic to locate the right keys on a keyboard,
                                    >you know, when needed. :)

                                    Oh phooey! :-P
                                    I'm sure you are a more experienced scripter than I am. I'll always
                                    be a klutz. I didn't mean what I said the way you took it, I think.
                                    There are several reasons for my procrastination. The biggest
                                    probably being that I don't need that advanced find operations very
                                    often. Without doubt the learning curve is steep and if you don't
                                    practice your skills you forget and have to start over again and
                                    again. If I had use for regex on a daily or even weekly or monthly
                                    basis, I would be on it like yesterday. As it is now, learning regex
                                    would mostly be a waste of time, because I wouldn't use it often
                                    enough to remember what I learnt for very long. I also find it
                                    extremely hard to read strings of squiggly characters. When I have to
                                    try to unwind one of those things I have sit with my finger on the
                                    screen or I'd miss half of it. So, since Notetab offers simpler ways
                                    to get things done I stick with those. Even if it sometimes gets
                                    convoluted and results in longwinded clips, that's most often enough
                                    for my humble needs.


                                    > > What does the J switch do though? I don't see it in Help.
                                    >It's under ^!Open "FileName" [/R] [/J=nnn] in Document Management section:

                                    An excellent example of how dumb I am. I looked under ^$GetLibraryFileName$.

                                    > > Yesterday I realized that my OnClipBoardChange clip sometimes
                                    > > screws up when the copied text contains quotes (but only
                                    > > sometimes)
                                    >Please do share if you find out more. I'm still somewhat timid when
                                    >it comes to playing with an active library, but your (new to me)
                                    >idea has opened some very interesting possibilities, as I was able
                                    >to put it into some immediate "useful use" with no unresolvable
                                    >glitches so far.

                                    Will do. I haven't been able to reproduce it with other quotes, so I
                                    now think there was something else that caused it. When it screwed up
                                    I copied a blog post, with heading, date stamp and so on. I'll go
                                    back there and try to make it happen again. There's probably some
                                    other character that needs to be replaced, maybe Unicode one.

                                    Lotta
                                  • loro
                                    ... If someone is still interested, we ve figured it out. At long last I realized it was line breaks in the copied text that screwed things up. Since I m
                                    Message 17 of 24 , Apr 22, 2010
                                    • 0 Attachment
                                      diodeom wrote:
                                      >lotta wrote
                                      > > Yesterday I realized that my OnClipBoardChange clip sometimes
                                      > > screws up when the copied text contains quotes (but only
                                      > > sometimes) and you end up with a broken heading like so
                                      > > H="heading
                                      > > "
                                      > > which messes up the following snips. A little odd. Maybe it
                                      > > was something else than quotes that made it happened even if
                                      > > I blamed the quotes at the time. Haven't looked into it yet.
                                      > >
                                      > > Lotta
                                      > >
                                      >
                                      >Please do share if you find out more. I'm still somewhat timid when
                                      >it comes to playing with an active library, but your (new to me)
                                      >idea has opened some very interesting possibilities, as I was able
                                      >to put it into some immediate "useful use" with no unresolvable
                                      >glitches so far.

                                      If someone is still interested, we've figured it out. At long last I
                                      realized it was line breaks in the copied text that screwed things
                                      up. Since I'm feebleminded and it only happened when I copied certain
                                      comments at a certain blog I set off on a wild goose chase, looking
                                      at different kinds of line endings and contemplating the possibility
                                      of corrupt characters. Diodeom immediately realized that the problem
                                      was caused by the clip cutting the string exactly between CR and LF
                                      and that it could be fixed with ^$StrFixLines()$. :-P

                                      I've compiled our efforts if someone wants it.

                                      __________[ ClipboardCollect ]__________

                                      H="Status On/Off"

                                      ^!Set %watch_clipboard%=^?{Watch clipboard==ON^=1|OFF^=0}


                                      H="Paste All"

                                      ^!Set %ww%=^$IsWordWrap$
                                      ^!Set %snips%=^%empty%
                                      ^!SetWordWrap off
                                      ^!SetScreenUpdate off

                                      ; Long line follows
                                      ^!Open "^$GetLibraryPath(^$GetLibraryName$)$^$GetLibraryName$.clb"
                                      ; End long line
                                      ^!Jump text_start
                                      ^!Find "^%sc%Text collected from clipboard""

                                      :loop
                                      ^!Jump select_end
                                      ^!Find "h="" SI
                                      ^!IfError do
                                      ^!Jump select_end
                                      ^!Set %start_pos%=^$GetRow$:^$GetCol$
                                      ^!Find """
                                      ^!Jump select_start
                                      ^!SelectTo ^%start_pos%
                                      ^!Set %this%=^$GetSelection$¤
                                      ^!Append %snips%=^%this%
                                      ^!Goto loop

                                      :do
                                      ^!Set %cntr%=0
                                      ^!SetListDelimiter ¤
                                      ; Long line follows
                                      ^!SetArray %snips%=^$StrDelete("^%snips%";^$StrSize("^%snips%")$;1)$
                                      ; End long line
                                      ^!Close
                                      ^!Menu File/new
                                      :paste-loop
                                      ^!Inc %cntr%
                                      ^!Clip "^%snips^%cntr%%"
                                      ; Long line follows
                                      ^!InsertText --------------------------------------^p
                                      ; End long line
                                      ^!If ^%cntr%=^%snips0% fini
                                      ^!Goto paste-loop

                                      :fini
                                      ^!If ^%ww%=1 next else end
                                      ^!SetWordWrap on


                                      H="Remove selected clips"

                                      ; ^!Open "^$GetLibraryFileName$" /J=-1
                                      ; Changed to work in 4.8 /loro
                                      ^!Open "^$GetLibraryPath(^$GetLibraryName$)$^$GetLibraryName$.clb"
                                      ^!Set %bot%=^$GetRow$:^$GetCol$
                                      ^!Find "^H\=";Text.++\R\K" WRS
                                      ^!SelectTo ^%bot%
                                      ^!SetListDelimiter |
                                      ^!Set %del%=^$GetDocMatchAll("^H\=\"\K(.+?)(?=\"$)")$
                                      ^!SetArray %del%=^?{(T=A;H=50)=^%del%}
                                      ^!Set %n%=0
                                      :Del
                                      ^!Inc %n%
                                      ^!If ^%n%>^%del0% Done
                                      ;Long line follows
                                      ^!Replace "\R\R\K\R*^H\=\"\Q^%del^%n%%\E\"$(?s).+?(?=(^H\=\"|\R*\Z))" >> "" WRS
                                      ;Long line end
                                      ^!Goto Del
                                      :Done
                                      ^!Replace "\R+\Z" >> "\r\n" WRS
                                      ^!Close Save
                                      ^!ClearVariable %bot%
                                      ^!ClearVariable %del%
                                      ^!ClearVariable %n%


                                      H="Clear collected text"

                                      ^!Set %ww%=^$IsWordWrap$
                                      ^!Set %curr_doc%=^$GetDocIndex$
                                      ^!SetWordWrap off
                                      ^!SetScreenUpdate off

                                      ^!Open "^$GetLibraryPath(^$GetLibraryName$)$^$GetLibraryName$.clb"
                                      ^!Jump text_start
                                      ^!Find "^%sc%Text collected from clipboard""
                                      ^!Jump select_end
                                      ^!Set %deltxt%=^$GetRow$:^$GetCol$
                                      ^!Jump text_end
                                      ^!SelectTo ^%deltxt%
                                      ^!Menu Edit/Delete
                                      ^!Save
                                      ^!Export "^##" ANSI
                                      ^!Close


                                      ^!SetDocIndex ^%curr_doc%
                                      ^!ReloadLibrary
                                      ^!If ^%ww%=1 next else end
                                      ^!SetWordWrap on


                                      H="_OnClipboardChange"

                                      ^!IfFalse ^%watch_clipboard% end else next

                                      ; Long line follows
                                      ^!AppendToFile
                                      "^$GetLibraryPath(^$GetLibraryName$)$^$GetLibraryName$.clb"
                                      ^%nl%^%nl%H="^$StrTrim("^$StrReplace("^p";"^%space%";"^$StrFixLines("^$StrCopy("^$GetClipboard$";1;50)$")$";false;false)$")$"^%nl%^$GetClipboard$^%nl%
                                      ; end long line
                                      ^!Sound ^$GetSoundPath$Click-9.wav
                                      ^!ReloadLibrary


                                      H=";Text collected from clipboard"
                                      _______________________


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