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

Re: [Clip] How to replace text in a string with clipcode?

Expand Messages
  • Axel Berger
    ... Every one of us went through that phase. Regardless of what language(s) you ve know before, Clips seems very strange at first. Looking at tips here, you ll
    Message 1 of 12 , Aug 14 5:42 AM
    • 0 Attachment
      Sherry wrote:
      > I feel clipcode is a really valuable concept but extremely tough

      Every one of us went through that phase. Regardless of what language(s)
      you've know before, Clips seems very strange at first. Looking at tips
      here, you'll find nearly everybody only uses a subset of commands he's
      become familiar with, I do.

      > "aa_bb_cc_dd_ee" should be replaced by "Aa Bb Cc Dd Ee"

      ^!Jump TEXT_START
      :loop
      ^!Find "\_\w" RST
      ;^!Continue
      ^!IfError fertig
      ^!InsertSelect ^$StrReplace("_";" ";"^$GetSelection$";False;False)$
      ;^!Continue
      ^!InsertText ^$StrUpper("^$GetSelection$")$
      ;^!Continue
      ^!Goto loop
      :fertig

      This is rather simple minded and ignores the first letter. To do more
      I'd need to know more about the regularities of your string (does it
      always have four underscores and always two letters betrween?) and how
      it relates to surrounding text.
    • flo.gehrke
      ... I doubt that this approach is the best lesson we could give to a beginner... 1. It doesn t capitalize the first letter of the string, so aa remains aa .
      Message 2 of 12 , Aug 14 7:31 AM
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
        >
        > > "aa_bb_cc_dd_ee" should be replaced by "Aa Bb Cc Dd Ee"
        >
        > ^!Jump TEXT_START
        > :loop
        > ^!Find "\_\w" RST
        > ;^!Continue
        > ^!IfError fertig
        > ^!InsertSelect ^$StrReplace("_";" ";"^$GetSelection$";False;False)$
        > ;^!Continue
        > ^!InsertText ^$StrUpper("^$GetSelection$")$
        > ;^!Continue
        > ^!Goto loop
        > :fertig

        I doubt that this approach is the best lesson we could give to a beginner...

        1. It doesn't capitalize the first letter of the string, so 'aa' remains 'aa'.

        2. The underscore '_' is no metacharacter, so there's no need to escape it here. (This goes to John as well.)

        3. Since a pure RegEx is used here, the T option doesn't make any sense.

        4. It was asked to limit the job to selected text whereas this clip affects the whole document.

        5. Why using ^!Find and that whole loop if the whole job would be done with...

        ^!Replace "_" >> "^%Space%" HATS
        ^!Toolbar Capitalize

        (limited to selected text).

        Regards,
        Flo
      • Axel Berger
        ... All your points are valid except this one. We are not told anything about the context, but my presumption is, this kind of string will occur many times in
        Message 3 of 12 , Aug 14 7:42 AM
        • 0 Attachment
          "flo.gehrke" wrote:
          > 5. Why using ^!Find and that whole loop if the whole job would be done with...
          > ^!Replace "_" >> "^%Space%" HATS
          > ^!Toolbar Capitalize
          > (limited to selected text).

          All your points are valid except this one. We are not told anything
          about the context, but my presumption is, this kind of string will occur
          many times in a longish document. If there was a need to highlight all
          of them individually first, we may as well drop the whole clip idea and
          do it all manually.

          > 1. It doesn't capitalize the first letter of the string, so 'aa' remains 'aa'.

          I said so myself. To tackle that one, I'd prefer to know more about the
          problem and its context. Selecting perhaps hundreds of instances by hand
          is not help at all IMHO.

          Axel
        • hsavage
          ... can t find a tutorial for Clipcode! A simple Hello World type code tutorial? I d like some hints for that! Not just a pointer to a file full of complicated
          Message 4 of 12 , Aug 14 3:40 PM
          • 0 Attachment
            Sherry wrote:
            > It's funny, I have worked with NoteTab Pro for a month and still
            can't find a tutorial for Clipcode! A simple Hello World type code
            tutorial? I'd like some hints for that! Not just a pointer to a file
            full of complicated clipcode. Maybe a short 5 min video tutorial with
            a simplest of all examples? Just a suggestion.
            >
            > My question is: How do I write a clip code that will replace all
            occurrences of _ with a space and then capitalize all words?
            >
            > for example
            >
            > "aa_bb_cc_dd_ee" should be replaced by "Aa Bb Cc Dd Ee"
            >
            > or maybe not replace in a string, but instead replace within a
            highlighted piece of text.
            >
            > Replacement in place is fine.
            >
            > Thanks in advance! I feel clipcode is a really valuable concept
            but extremely tough to crack into! For example, I am proficient with
            Xemacs macros, and they are easy to define.... at least for me!
            >
            > Thanks again! Sherry

            Sherry,

            Reg-exp has been pretty well covered for your problem. Here's a
            simple clip language method to resolve your request.

            It does nothing more or less than you asked with your example. I
            hope you can copy and paste this into a library to use, if you don't
            know how reply back to this clips list.

            ----------------------------------
            H="Replace Underscore & Capitalize"
            ;_WITHOUT REG-EXP
            ;_
            ^!If ^$GetSelSize$ = 0 NEXT ELSE SOMETHING_SELECTED
            :NOTHING_SELECTED
            ;_With nothing selected this 3 line group executes whole document
            ^!Replace "_" >> " " TWSA
            ^!Select ALL
            ^!GoTo END
            ;_
            :SOMETHING_SELECTED
            ^!If ^$GetSelSize$ > 0 NEXT ELSE END
            ;_With selection made these last 2 lines execute on selected text
            ^!Replace "_" >> " " THSA
            :END
            ^$StrCapitalize("^$GetSelection$")$
            ------------------------------------

            ·············································
            ºvº SL_day# 226 - created 2010.08.14_17.15.01

            Party Etiquette; Drinking Your Fair Share.

            € hrs € hsavage € pobox € com
          • Eb
            I d like to add a couple of points to Flo s comments. ... Using a RegExp is definitely NOT a beginner-level tool in the first place. ... Instead of Toolbar,
            Message 5 of 12 , Aug 16 1:05 AM
            • 0 Attachment
              I'd like to add a couple of points to Flo's comments.


              --- In ntb-clips@yahoogroups.com, "flo.gehrke" <flo.gehrke@...> wrote:
              >
              > I doubt that this approach is the best lesson we could give to a beginner...

              > 3. Since a pure RegEx is used here, the T option doesn't make any sense.

              Using a RegExp is definitely NOT a beginner-level tool in the first place.



              > ^!Replace "_" >> "^%Space%" HATS
              > ^!Toolbar Capitalize

              Instead of Toolbar, the Menu command would be better, because it is much easier to find it's available options:

              ^!Replace "_" >> "^%Space%" HATS
              ^!Menu Modify/"Text Case"/Capitalize

              As to a tutorial, clicking on the SECOND help itme in NoteTab (Help on Clip Programming) leads you to an excellent tutorial, albeit you will actually have to read stuff without pictures ;-).
              Read the introductions of each topic, skim through the various commands and functions may get you started.

              I have always thought that NoteTabs help is far superior to the average software help (a la Microsoft: "Check the 'Snaggle' option to enable 'snaggle'"). Its only major flaw is, that the list of help topics in Clip Programming is not alphabetized, making it difficult to find things.

              On the other hand, the existing topics are roughly in the order of importance for a beginner.



              Cheers,

              Eb.
            • Don
              ... And the group support here is second to none! But having said that, any suggested solution is help being given so let s not be too critical of each others
              Message 6 of 12 , Aug 16 5:07 AM
              • 0 Attachment
                > I have always thought that NoteTabs help is far superior to the average software help (a la Microsoft: "Check the 'Snaggle' option to enable 'snaggle'"). Its only major flaw is, that the list of help topics in Clip Programming is not alphabetized, making it difficult to find things.
                >
                And the group support here is second to none!

                But having said that, any suggested solution is help being given so let's not be too critical of each others volunteer offers of help is my suggestion.
              • Axel Berger
                ... There is an alphabetic list with one important snag: ^? , the details of which I always forget, is not in it and quite hard to find every time, meaning
                Message 7 of 12 , Aug 16 5:28 AM
                • 0 Attachment
                  Eb wrote:
                  > On the other hand, the existing topics are roughly in the order
                  > of importance for a beginner.

                  There is an alphabetic list with one important snag: "^?", the details
                  of which I always forget, is not in it and quite hard to find every
                  time, meaning the /obvious place/ "variables" is not that obvious to me.

                  But far more important to this thread, we seem to have lost Sherry,
                  which is a shame. I still believe any solution that forces her to
                  highlight each and every occurrence of the string manually is no help at
                  all, but I do need more input to provide a solution that is.

                  N.B: My clips tend to be rather primitive and brain dead on purpose,
                  e.g. using several primitive lines when a single one would suffice. It
                  not only makes them more easily legible for beginners but also for
                  myself, when I need to remind myself, what that clip, written months
                  ago, actually does. I admire diodeom's one-liners but for me at least,
                  they are quite hard to understand.

                  Sherry, if you're still with us: don't be put off by our internal digs
                  between the "experts", we're really all trying to help.

                  Axel
                • flo.gehrke
                  ... Eb, For a better overview, Ray Fitzgerald created his ToolTips.CLB, last updated in Feb 2000. It s in the ClipClass+Clip Basics+more.ZIP file that Alec
                  Message 8 of 12 , Aug 17 2:56 AM
                  • 0 Attachment
                    --- In ntb-clips@yahoogroups.com, "Eb" <ebbtidalflats@...> wrote:

                    > > ^!Replace "_" >> "^%Space%" HATS
                    > > ^!Toolbar Capitalize
                    >
                    > Instead of Toolbar, the Menu command would be better, because it
                    > is much easier to find it's available options:
                    >
                    > ^!Replace "_" >> "^%Space%" HATS
                    > ^!Menu Modify/"Text Case"/Capitalize

                    Eb,

                    For a better overview, Ray Fitzgerald created his ToolTips.CLB, last updated in Feb 2000. It's in the ClipClass+Clip Basics+more.ZIP file that Alec uploaded to the File section of this group in Dec 2008.

                    I found it quite useful. Checking it against the latest ^!Toolbar options in NT 6.2, I found two issues:

                    1. "Printer Settings" doesn't work in NT 6.2 and returns an error message. So you better delete it.

                    2. There is a "Page Setup" option in NT 6.2 but not in that clipbook. One may add this option in order to see all valid options.

                    Regards,
                    Flo
                  • Eb
                    Thanks, Flo, I agree, and the most useful file, Toolbar.txt contains the descriptions missing from the NoteTab Help file. The clip library isn t bad either,
                    Message 9 of 12 , Aug 20 11:51 AM
                    • 0 Attachment
                      Thanks, Flo,

                      I agree, and the most useful file, "Toolbar.txt" contains the descriptions missing from the NoteTab Help file.

                      The clip library isn't bad either, though somewhat confusing.

                      See the "Help with clips" post for a suggestion to clippers, how to avoid such confusion.



                      Cheers,

                      Eb


                      --- In ntb-clips@yahoogroups.com, "flo.gehrke" <flo.gehrke@...> wrote:
                      >
                      > --- In ntb-clips@yahoogroups.com, "Eb" <ebbtidalflats@> wrote:
                      >
                      > > > ^!Replace "_" >> "^%Space%" HATS
                      > > > ^!Toolbar Capitalize
                      > >
                      > > Instead of Toolbar, the Menu command would be better, because it
                      > > is much easier to find it's available options:
                      > >
                      > > ^!Replace "_" >> "^%Space%" HATS
                      > > ^!Menu Modify/"Text Case"/Capitalize
                      >
                      > Eb,
                      >
                      > For a better overview, Ray Fitzgerald created his ToolTips.CLB, last updated in Feb 2000. It's in the ClipClass+Clip Basics+more.ZIP file that Alec uploaded to the File section of this group in Dec 2008.
                      >
                      > I found it quite useful. Checking it against the latest ^!Toolbar options in NT 6.2, I found two issues:
                      >
                      > 1. "Printer Settings" doesn't work in NT 6.2 and returns an error message. So you better delete it.
                      >
                      > 2. There is a "Page Setup" option in NT 6.2 but not in that clipbook. One may add this option in order to see all valid options.
                      >
                      > Regards,
                      > Flo
                      >
                    • Sherry
                      Hello, Thank you so much, EVERYONE, for answering my request. I am sorry for not responding earlier. But I did read the discussion and finally today I am in
                      Message 10 of 12 , Aug 22 4:39 AM
                      • 0 Attachment
                        Hello,

                        Thank you so much, EVERYONE, for answering my request. I am sorry for not responding earlier. But I did read the discussion and finally today I am in the need of the code.

                        Again, I am sorry for not communicating earlier, requiring you to read my mind ;)

                        I picked this code below, and, having inserted it into my HTML.clb library, it works like a charm. (Had to get admin privileges to add/modify the library). That is exactly what I wanted. Someday when I need more, I will study the code and modify if needed.

                        I really appreciate the responsiveness of everyone in the group, you guys rock! There is something very satisfying to have a simple code do wonders with my text ;)

                        Greetings, and have a great rest of the weekend!

                        Sherry

                        --- In ntb-clips@yahoogroups.com, hsavage <hsavage@...> wrote:
                        >
                        > Sherry wrote:
                        > > It's funny, I have worked with NoteTab Pro for a month and still
                        > can't find a tutorial for Clipcode! A simple Hello World type code
                        > tutorial? I'd like some hints for that! Not just a pointer to a file
                        > full of complicated clipcode. Maybe a short 5 min video tutorial with
                        > a simplest of all examples? Just a suggestion.
                        > >
                        > > My question is: How do I write a clip code that will replace all
                        > occurrences of _ with a space and then capitalize all words?
                        > >
                        > > for example
                        > >
                        > > "aa_bb_cc_dd_ee" should be replaced by "Aa Bb Cc Dd Ee"
                        > >
                        > > or maybe not replace in a string, but instead replace within a
                        > highlighted piece of text.
                        > >
                        > > Replacement in place is fine.
                        > >
                        > > Thanks in advance! I feel clipcode is a really valuable concept
                        > but extremely tough to crack into! For example, I am proficient with
                        > Xemacs macros, and they are easy to define.... at least for me!
                        > >
                        > > Thanks again! Sherry
                        >
                        > Sherry,
                        >
                        > Reg-exp has been pretty well covered for your problem. Here's a
                        > simple clip language method to resolve your request.
                        >
                        > It does nothing more or less than you asked with your example. I
                        > hope you can copy and paste this into a library to use, if you don't
                        > know how reply back to this clips list.
                        >
                        > ----------------------------------
                        > H="Replace Underscore & Capitalize"
                        > ;_WITHOUT REG-EXP
                        > ;_
                        > ^!If ^$GetSelSize$ = 0 NEXT ELSE SOMETHING_SELECTED
                        > :NOTHING_SELECTED
                        > ;_With nothing selected this 3 line group executes whole document
                        > ^!Replace "_" >> " " TWSA
                        > ^!Select ALL
                        > ^!GoTo END
                        > ;_
                        > :SOMETHING_SELECTED
                        > ^!If ^$GetSelSize$ > 0 NEXT ELSE END
                        > ;_With selection made these last 2 lines execute on selected text
                        > ^!Replace "_" >> " " THSA
                        > :END
                        > ^$StrCapitalize("^$GetSelection$")$
                        > ------------------------------------
                        >
                        > ·············································
                        > ºvº SL_day# 226 - created 2010.08.14_17.15.01
                        >
                        > Party Etiquette; Drinking Your Fair Share.
                        >
                        > € hrs € hsavage € pobox € com
                        >
                      Your message has been successfully submitted and would be delivered to recipients shortly.