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

Re: [Clip] Help with text formatting search and replace

Expand Messages
  • hsavage
    ... Sharon, This 3 line clip does automatically what I tried to describe above and it s very easy to break down to figure out the operation. H= Event lines
    Message 1 of 12 , Feb 15, 2003
    • 0 Attachment
      hsavage wrote:

      >Sharon wrote:
      >
      >
      >
      >>I've got text cut-and-pasted from a Web site like so:
      >>
      >>Tonight
      >>Explainer of events going on tonight.
      >>Saturday
      >>Explainer of events going on Saturday.
      >>Saturday Night
      >>Explainer of events going on Sunday.
      >>
      >>etc. I've been trying to figure out how to automate the process of
      >>turning that format into the format below (which I'll then use as
      >>part of an e-mail message)
      >>
      >>Tonight - Explainer of events going on tonight.
      >>
      >>Saturday - Explainer of events going on tonight.
      >>
      >>etc. I figured out how to remove the beginning space from each line
      >>(one line at a time, highlighting the lines line by line manually --
      >>Any help much appreciated! Thanks, Sharon
      >>
      >>
      >Sharon,
      >
      >That will eliminate the leading spaces, spaces on left of sentence. The
      >other option is drop down menu - Modify>Alignment>Left Align. This too,
      >will eliminate the spaces.
      >
      >Next, open the Replace dialog on the toolbar or menu Search>Replace or
      >Ctrl+R. Either should open the Replace dialog.
      >
      >This should give you exactly what you requested.
      >
      >hrs
      >
      >
      Sharon,

      This 3 line clip does automatically what I tried to describe above and
      it's very easy to break down to figure out the operation.


      H="Event lines formatter"
      ^!Select ALL
      ^!Menu Modify/Alignment/Left Align
      ^!Replace "^pExplainer" >> " - Explainer" IWSA


      I created a larger file of repetitions of your example and it worked fine.

      hrs

      Tonight
      Explainer of events going on tonight.
      Saturday
      Explainer of events going on Saturday.
      Saturday Night
      Explainer of events going on Sunday.
      Tonight
      Explainer of events going on tonight.
      Saturday
      Explainer of events going on Saturday.
      Saturday Night
      Explainer of events going on Sunday.
    • Sharon <sharon@kc1yr.com>
      Thanks RS, Jody, hsavage and Alec for the help and explainers. Not only do I have a working clip to do what needs to be done, I ve learned something! This has
      Message 2 of 12 , Feb 15, 2003
      • 0 Attachment
        Thanks RS, Jody, hsavage and Alec for the help and explainers. Not
        only do I have a working clip to do what needs to be done, I've
        learned something! This has been very helpful.

        Regarding this:

        --- In ntb-clips@yahoogroups.com, RS <ptools@w...> wrote:
        > As an afterthought, we could have used ^!Replace commands, instead,
        to process all the action directly on the document. Both ways are
        effective. Here's how:
        >
        > ;======== Start ========
        > H="Format 2 lines #001"
        > ; @ 20030214_1919
        >
        > ^!If ^$GetSelection$= "" End
        >
        > ^!Replace "^%NL%" >> "@@" AISH
        > ^!Replace "@@ " >> "^%NL%" AISH
        > ^!Replace "@@" >> " - " AISH
        > ^!Toolbar "Left Align"
        > ;========= End =========

        that helps a lot. I was confused about the string replace commands in
        your first clip, because I'd never worked with those before -- I've
        been using the ^!Replace command. Reminds me of what they keep saying
        in Perl, "there's more than one way to do things." :-) (speaking of
        which, I tried using ^p instead of ^%NL% and that seemed to work as
        well). So it *is* possible to use the ^!Replace too, I just wasn't
        doing it correctly.

        Anyway, with this model, I believe I'll be able to write more of my
        own text formatting clips. Thanks again!

        Sharon
      • hsavage
        ... Sharon, I hate to belabor the point but at first I thought your sample (example) was a literal example. I think I have figured out that the word
        Message 3 of 12 , Feb 15, 2003
        • 0 Attachment
          Sharon wrote:

          >Thanks RS, Jody, hsavage and Alec for the help and explainers. Not
          >only do I have a working clip to do what needs to be done, I've
          >learned something! This has been very helpful.
          >
          >Regarding this:
          >
          >that helps a lot. I was confused about the string replace commands in
          >your first clip, because I'd never worked with those before -- I've
          >been using the ^!Replace command. Reminds me of what they keep saying
          >in Perl, "there's more than one way to do things." :-) (speaking of
          >which, I tried using ^p instead of ^%NL% and that seemed to work as
          >well). So it *is* possible to use the ^!Replace too, I just wasn't
          >doing it correctly.
          >
          >Anyway, with this model, I believe I'll be able to write more of my
          >own text formatting clips. Thanks again!
          >
          >Sharon
          >
          >
          Sharon,

          I hate to belabor the point but at first I thought your sample (example)
          was a literal example. I think I have figured out that the word
          'Explainer' is not an actual part of your text file.

          With this latest clip, be sure to read the comments, it doesn't matter
          if the word 'Explainer' is there or not.

          If nothing else, this clip gives you another option to examine.

          hrs


          H="Event lines formatter"
          ; don't preselect anything, place cursor on first line,
          ; ie, Today, Saturday, Saturday Night
          ; with Goto commented out it will do a 'day' at a time
          ; remove semicolon to do multiples until a blank line is reached
          :LOOP
          ^!Select Line
          ^!If ^$GetSelection$="" END
          ^!Replace "^p" >> " - " S
          ^!ToolBar Left Align
          ^!Jump +1
          ;^!Goto LOOP
        • Sharon <sharon@kc1yr.com>
          This isn t belaboring the point at all, I wanted to learn from this exercise and indeed I m learning! I ve never tried using a loop with the clip language, so
          Message 4 of 12 , Feb 15, 2003
          • 0 Attachment
            This isn't belaboring the point at all, I wanted to learn from this
            exercise and indeed I'm learning! I've never tried using a loop with
            the clip language, so this is another useful option to examine. And
            it does work perfectly, going through the whole text or doing it line
            by line manually if the goto line is commented out.

            I've written a couple of scripts in Perl to capture text from a
            Web site and then format it; I might look to see if I can some
            of that in a clip. I just bought Pro this week, and see I can somehow
            integrate Perl scripts in there. More weekend fun! :-)

            Thanks!

            --- In ntb-clips@yahoogroups.com, hsavage <hsavage@p...> wrote:
            > Sharon,
            >
            > I hate to belabor the point but at first I thought your sample
            (example)
            > was a literal example. I think I have figured out that the word
            > 'Explainer' is not an actual part of your text file.
            >
            > With this latest clip, be sure to read the comments, it doesn't
            matter
            > if the word 'Explainer' is there or not.
            >
            > If nothing else, this clip gives you another option to examine.
            >
            > hrs
            >
            >
            > H="Event lines formatter"
            > ; don't preselect anything, place cursor on first line,
            > ; ie, Today, Saturday, Saturday Night
            > ; with Goto commented out it will do a 'day' at a time
            > ; remove semicolon to do multiples until a blank line is reached
            > :LOOP
            > ^!Select Line
            > ^!If ^$GetSelection$="" END
            > ^!Replace "^p" >> " - " S
            > ^!ToolBar Left Align
            > ^!Jump +1
            > ;^!Goto LOOP
          • Jody
            Hi Jody, ... [Non-text portions of this message have been removed]
            Message 5 of 12 , Feb 21, 2003
            • 0 Attachment
              Hi Jody,
              You wrote:
              >Hi Sharon and Others,
              >
              >>The InsertText replaces the selected text with the contents of the %s% variable.
              >>
              >>^!InsertText ^$StrTrim("^%s%")$
              >
              >The ^!InsertText in this case is not needed, and actually, a lot of
              >the time it is not needed. It does however save some headaches
              >when trying to figure out why you are or are not getting a blank
              >line or why or why not the text is wrapped. If you were to go back
              >to the early days of v3 and 4 you would see a lot of the Clips that
              >the text was plain black text, a lot of it in the HTML Library. We
              >have better commands to use today though so those are used so that
              >empty attributes in tags don't get inserted into the document.
              >You'll also find that ^!Insert does the same thing as ^!InsertText.
              >
              >One of the unique things about the Clip code is if you have
              >regular text you want pasted in the document you can simply add
              >it in the Clip with no command in front of it. In the case of
              >the Clip the "^$StrTrim("^%s%")$" simply trims the contents of
              >"^%s%" (takes leading and trailing spaces out) and then it gets
              >"pasted" over the selection. If there was no text selected, then
              >it would be inserted wherever the cursor is. Notice where the
              >second "some text" gets pasted. Experiment putting ^p in the
              >^!InsertText and on a line with just the "^$StrTrim("^%s%")$" use
              >^%nl% before and after to see what it does: ^%nl%^$StrTrim("^%s%")$
              >
              ><--- Copy below this line --->
              >H=Some Text
              >; eMailed on 02-15-2003, Jody@...
              >; notetab.net, notetab.net/html/cd-info.htm
              >
              >^!Set %s%=" Some Text "
              >^$StrTrim("^%s%")$
              >^!Info Peek
              >^!InsertText ^$StrTrim("^%s%")$
              ><--- Copy above this line --->
              ><--- Right click over a Library --->
              ><--- Choose: Add from Clipboard --->
              >
              >
              >Happy Clip'n!
              >Jody
              >
              ><http://www.notetab.net>http://www.notetab.net
              >
              >Subscribe, UnSubscribe, Options
              >mailto:Ntb-Clips-Subscribe@yahoogroups.com
              >mailto:Ntb-Clips-UnSubscribe@yahoogroups.com
              ><http://groups.yahoo.com/group/ntb-clips>http://groups.yahoo.com/group/ntb-clips
              >
              >
              >Your use of Yahoo! Groups is subject to the <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.