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

Selective Updates

Expand Messages
  • John Shotsky
    I ve encountered another clip coding problem that I can t seem to figure out - hoping someone can help. I have several thousand lines of text in a file. There
    Message 1 of 9 , Oct 16, 2008
    • 0 Attachment
      I've encountered another clip coding problem that I can't seem to figure out - hoping someone can help.

      I have several thousand lines of text in a file. There are certain keywords that activate a section that I want to process, and I
      want to end the processing with a blank line. I have tried several variations, but always end up processing rows that should not be
      processed. I have probably WAY over-complicated it.

      Input text:
      <Random text until Start Tag encountered
      This is text to ignore
      This is text to ignore
      This is text to ignore
      This is text to ignore
      Start Tag: <I want to begin processing here
      This is text to ignore
      This is text to ignore
      This is text to ignore
      This is text to ignore
      This Text should be processed
      This is text to ignore
      This is text to ignore
      <This blank line stops processing until the next start tag
      This is text to ignore
      This is text to ignore
      Start Tag: <I want to begin processing here
      This is text to ignore
      This is text to ignore
      This Text should be processed

      Output text:
      This is text to ignore
      This is text to ignore
      This is text to ignore
      This is text to ignore
      Start Tag:
      This is text to ignore
      This is text to ignore
      This is text to ignore
      This is text to ignore
      Processed: This Text should be processed
      This is text to ignore
      This is text to ignore

      This is text to ignore
      This is text to ignore
      Start Tag:
      This is text to ignore
      This is text to ignore
      Processed: This Text should be processed

      Thanks for any assistance!
      John




      [Non-text portions of this message have been removed]
    • Don - HtmlFixIt.com
      ... This makes no sense to me. I have no idea what criteria cause text to be ignored or processed. I have no idea what your clip looks like.
      Message 2 of 9 , Oct 16, 2008
      • 0 Attachment
        John Shotsky wrote:
        > I've encountered another clip coding problem that I can't seem to figure out - hoping someone can help.
        >
        > I have several thousand lines of text in a file. There are certain keywords that activate a section that I want to process, and I
        > want to end the processing with a blank line. I have tried several variations, but always end up processing rows that should not be
        > processed. I have probably WAY over-complicated it.
        >
        > Input text:
        > <Random text until Start Tag encountered
        > This is text to ignore
        > This is text to ignore
        > This is text to ignore
        > This is text to ignore
        > Start Tag: <I want to begin processing here
        > This is text to ignore
        > This is text to ignore
        > This is text to ignore
        > This is text to ignore
        > This Text should be processed
        > This is text to ignore
        > This is text to ignore
        > <This blank line stops processing until the next start tag
        > This is text to ignore


        This makes no sense to me. I have no idea what criteria cause text to
        be ignored or processed. I have no idea what your clip looks like.
      • John Shotsky
        Sorry, I thought it was clear. I want to ignore all text except lines between a start tag and an empty line. I don t want to modify all lines between the start
        Message 3 of 9 , Oct 16, 2008
        • 0 Attachment
          Sorry, I thought it was clear. I want to ignore all text except lines between a start tag and an empty line. I don't want to modify
          all lines between the start and end zone, only certain ones. So, in my example, only the line named 'This Text should be processed'
          should be changed (actually, a word added), the others should be skipped. The text itself is the criteria.

          John

          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Don - HtmlFixIt.com
          Sent: Thursday, October 16, 2008 6:58 PM
          To: ntb-clips@yahoogroups.com
          Subject: Re: [Clip] Selective Updates

          John Shotsky wrote:
          > I've encountered another clip coding problem that I can't seem to figure out - hoping someone can help.
          >
          > I have several thousand lines of text in a file. There are certain keywords that activate a section that I want to process, and I
          > want to end the processing with a blank line. I have tried several variations, but always end up processing rows that should not
          be
          > processed. I have probably WAY over-complicated it.
          >
          > Input text:
          > <Random text until Start Tag encountered
          > This is text to ignore
          > This is text to ignore
          > This is text to ignore
          > This is text to ignore
          > Start Tag: <I want to begin processing here
          > This is text to ignore
          > This is text to ignore
          > This is text to ignore
          > This is text to ignore
          > This Text should be processed
          > This is text to ignore
          > This is text to ignore
          > <This blank line stops processing until the next start tag
          > This is text to ignore

          This makes no sense to me. I have no idea what criteria cause text to
          be ignored or processed. I have no idea what your clip looks like.



          [Non-text portions of this message have been removed]
        • Axel Berger
          ... You start with a ^!Find. The blank line is R R in Regex. After that you use ^!Replace s with the H option set, making them work in the highlighted area
          Message 4 of 9 , Oct 17, 2008
          • 0 Attachment
            John Shotsky wrote:
            > There are certain keywords that activate a section that I want
            > to process, and I want to end the processing with a blank line.

            You start with a ^!Find. The blank line is "\R\R" in Regex.
            After that you use ^!Replace s with the H option set, making them work
            in the highlighted area only.

            Axel
          • John Shotsky
            I understand how to do it generally. I spent hours trying to get it to work properly, and yet it fails somewhere. I use a combination of two loops, with finds
            Message 5 of 9 , Oct 17, 2008
            • 0 Attachment
              I understand how to do it generally. I spent hours trying to get it to work properly, and yet it fails somewhere. I use a
              combination of two loops, with finds and replaces.but It still only changes one instance within the inside loop, or it changes
              things outside the tags.

              Generally, this is what I've tried:
              Go to start of doc
              :Loop1
              Find Start tag
              If error end
              :Loop2
              Increment one line
              Select the line
              Replace 'x' with 'yx' within selection
              If error empty else loop2
              :empty
              Find ^\R within selection
              If error loop2 else Loop1
              :End

              Apparently, the :empty test doesn't function correctly, because lines outside loop1 get processed. Nothing should ever be processed
              after a blank line unless a start tag is encountered. I am probably stuck in a dumb loop, or one of the tests doesn't function as I
              think it should.

              Thanks,
              John


              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
              Sent: Friday, October 17, 2008 2:43 AM
              To: ntb-clips@yahoogroups.com
              Subject: Re: [Clip] Selective Updates

              John Shotsky wrote:
              > There are certain keywords that activate a section that I want
              > to process, and I want to end the processing with a blank line.

              You start with a ^!Find. The blank line is "\R\R" in Regex.
              After that you use ^!Replace s with the H option set, making them work
              in the highlighted area only.

              Axel



              [Non-text portions of this message have been removed]
            • Axel Berger
              ... I can t quite follow your pseudocode, but it s not what I had thought about. I meant: ^!Find (?s) (.+?) R R RI ^!Replace whatever whatnow HAS
              Message 6 of 9 , Oct 17, 2008
              • 0 Attachment
                John Shotsky wrote:
                > Generally, this is what I've tried:

                I can't quite follow your pseudocode, but it's not what I had thought
                about. I meant:

                ^!Find "(?s)<Tag>(.+?)\R\R" RI
                ^!Replace "whatever" >> "whatnow" HAS

                (Is "(?s)" the code for dotall? Too lazy to look right now.)

                Axel
              • John Shotsky
                I fear I have still not made the problem clear. This text file has 10000 lines. There are 100 tags spread around in this text file where processing is to be
                Message 7 of 9 , Oct 17, 2008
                • 0 Attachment
                  I fear I have still not made the problem clear.

                  This text file has 10000 lines. There are 100 tags spread around in this text file where processing is to be performed. These areas
                  are terminated by a blank line. No processing is permitted between a blank line and a start tag.

                  Within each processing area, there are many lines. Some of those lines get changed, the rest don't. It could be every other line,
                  only one line, no lines, or every line.To simplify the example, I'll say the word CAT (upper case) is always found in lines that
                  must be processed, but it is also found in lines OUTSIDE the processing areas, and those lines are not to be processed.

                  I want one clip to process the entire file and make only those changes that are appropriate, and only within processing sections. My
                  CURRENT approach processes OUTSIDE the processing areas, which means to me that the blank line is being ignored. I didn't want to
                  show my code because I wanted to see how others would approach this problem in case I'm thinking about it wrong. (If I'm doing it
                  the hard way, I don't simply want to fix a bad line, I want to do the task in a more elegant way.)

                  But it is clear that there have to be two loops - one to go from processing area to processing area, and one to process lines within
                  each processing area.

                  In the example below, there are no loops, so I don't see how it could work.

                  Thanks,
                  John

                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                  Sent: Friday, October 17, 2008 6:44 AM
                  To: ntb-clips@yahoogroups.com
                  Subject: Re: [Clip] Selective Updates

                  John Shotsky wrote:
                  > Generally, this is what I've tried:

                  I can't quite follow your pseudocode, but it's not what I had thought
                  about. I meant:

                  ^!Find "(?s)<Tag>(.+?)\R\R" RI
                  ^!Replace "whatever" >> "whatnow" HAS

                  (Is "(?s)" the code for dotall? Too lazy to look right now.)

                  Axel



                  [Non-text portions of this message have been removed]
                • Axel Berger
                  ... There is. A replace with an A is a sort of implicit loop, doing A ll occurrences. I had not understood about more than one areas. So yes, you do need to
                  Message 8 of 9 , Oct 17, 2008
                  • 0 Attachment
                    John Shotsky wrote:
                    > In the example below, there are no loops, so I don't see how it could work.

                    There is. A replace with an "A" is a sort of implicit loop, doing "A"ll
                    occurrences. I had not understood about more than one areas. So yes, you
                    do need to loop the ^!Find.

                    Axel
                  • junja
                    ... You re right. (Don t take any notice of this if someone else is helping you.) There has to be something in your code to instantiate each of the
                    Message 9 of 9 , Oct 18, 2008
                    • 0 Attachment
                      John Shotsky wrote:

                      > But it is clear that there have to be two loops - one to go from processing area to processing area, and one to process lines within
                      > each processing area.

                      You're right.
                      (Don't take any notice of this if someone else is helping
                      you.)

                      There has to be something in your code to instantiate
                      each of the requirements you're posing.

                      It seems to me you want to do something concrete to
                      prevent the clip altering stuff outside the current block
                      (which is delimited by blank lines above and below, no ?) .
                      One way of doing that would be to:
                      - search for next blank line
                      - place the cursor at start of that (or the next) line
                      - record the cursor position
                      - search for next blank line
                      - place the cursor at start of that line
                      - select (back) to the saved cursor position
                      - do any wanted replaces inside the selected text

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