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

Handling periods at ends of lines

Expand Messages
  • John Shotsky
    I have a problem that I just can t seem to fix correctly. (Periods is only one example - I have this problem with several clips using other characters, like
    Message 1 of 23 , Apr 6, 2009
    • 0 Attachment
      I have a problem that I just can't seem to fix correctly. (Periods is only one example - I have
      this problem with several clips using other characters, like \x20, also.



      I want to find certain lines and add a period only if there isn't one already. If there is
      already a period, I want to leave it, but if there is not one, I want to add one. It would be ok
      to remove an existing one and replace it with a new one, of course. But it has to work only on
      the lines I search on.



      Here are example lines: (I only care about the end, not periods that are elsewhere in a line.)



      This is an example line without a period

      This is an example line with a period.



      I use a clip like this:

      ^!Replace "^(This is an example line.+)\.?\R" >> "$1\.\n" ARSTW



      What happens is that both lines get a new period, the second example ends up with 2.



      I am thinking the .+ is too aggressive, but I haven't hit on the right combination to ensure
      that I don't get two periods. I can't use \.+ on the period, because it would not match if there
      wasn't one. I'm sure this is really fundamental, but I haven't figured it out yet, with lots of
      playing around with it. I've just written error correction clips to remove the doubles when they
      happen. Bad.



      Thanks in advance,

      John





      [Non-text portions of this message have been removed]
    • Sheri
      ... Try it this way, untested but should work: ^!IfFalse ^$GetSelSize$ Next Else Skip_2 ^!Prompt This clip requires a selection. ^!Goto End ^!Replace
      Message 2 of 23 , Apr 6, 2009
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
        >
        > I want to find certain lines and add a period only if there isn't
        > one already. If there is already a period, I want to leave it,
        > but if there is not one, I want to add one. It would be ok to
        > remove an existing one and replace it with a new one, of course.
        > But it has to work only on the lines I search on.

        Try it this way, untested but should work:


        ^!IfFalse ^$GetSelSize$ Next Else Skip_2
        ^!Prompt This clip requires a selection.
        ^!Goto End
        ^!Replace "[^\r\n.]\K$" >> "." RAHS

        Regards,
        Sheri
      • John Shotsky
        Thanks Sheri, but I really need it to work on the whole document, finding only the lines specified in the find part of the command. My documents have thousands
        Message 3 of 23 , Apr 6, 2009
        • 0 Attachment
          Thanks Sheri, but I really need it to work on the whole document, finding only the lines
          specified in the find part of the command. My documents have thousands of lines, and only a few
          need to be changed. Essentially, I am looking for sentences that have lost or were never given a
          period, but there are many more lines that are not sentences and should never get a period
          added.



          I'm reasonably certain it can be done using a replace statement such as I am using (so I can
          control what is found), but with some element that prevents the double periods. I've thought
          about using a class that includes everything but a period, but I think that would be really
          slow.



          As it is, it is actually pretty fast, but I dislike having to correct errors that are created by
          clips I write! J



          PS: Oddly enough, as I was playing with it some more, I found the magic solution: 1 measly
          question mark makes it work correctly.

          ^!Replace "^(This is an example line.+?)\.?\R" >> "$1\.\n" ARSTW



          John



          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Sheri
          Sent: Monday, April 06, 2009 2:44 PM
          To: ntb-clips@yahoogroups.com
          Subject: [Clip] Re: Handling periods at ends of lines



          --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky"
          <jshotsky@...> wrote:
          >
          > I want to find certain lines and add a period only if there isn't
          > one already. If there is already a period, I want to leave it,
          > but if there is not one, I want to add one. It would be ok to
          > remove an existing one and replace it with a new one, of course.
          > But it has to work only on the lines I search on.

          Try it this way, untested but should work:

          ^!IfFalse ^$GetSelSize$ Next Else Skip_2
          ^!Prompt This clip requires a selection.
          ^!Goto End
          ^!Replace "[^\r\n.]\K$" >> "." RAHS

          Regards,
          Sheri





          [Non-text portions of this message have been removed]
        • Flo
          ... Try this (corrected -- sorry!)... ^!Replace ^(This is an example line[^. r n]*)(?!.) $1. AWRS Flo
          Message 4 of 23 , Apr 6, 2009
          • 0 Attachment
            --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
            >
            > I really need it to work on the whole document, finding only
            > the lines specified in the find part of the command.
            > I'm reasonably certain it can be done using a replace statement
            > such as I am using (so I can control what is found), but with some
            > element that prevents the double periods.

            Try this (corrected -- sorry!)...

            ^!Replace "^(This is an example line[^.\r\n]*)(?!.)" >> "$1." AWRS

            Flo
          • Alec Burgess
            John Shotsky (jshotsky@comcast.net) wrote (in part) (on 2009-04-06 at ... beating the dead horse department .... Hi John: The cleanest way to do it is with
            Message 5 of 23 , Apr 6, 2009
            • 0 Attachment
              John Shotsky (jshotsky@...) wrote (in part) (on 2009-04-06 at
              18:25):
              >
              > PS: Oddly enough, as I was playing with it some more, I found the
              > magic solution: 1 measly
              > question mark makes it work correctly.
              >
              > ^!Replace "^(This is an example line.+?)\.?\R" >> "$1\.\n" ARSTW

              beating the dead horse department ....

              Hi John:
              The "cleanest" way to do it is with a negative lookbehind:
              ^!replace "(?m)(?<!\.)$" >> "." rwsai
              (?m) forces ^ and $ to match at linebreaks ... not really needed since
              that is the default in Notetab 5
              (?<!\.) is negative lookbehind

              Another way is:
              ^!replace "(?m)([^\.])$" >> "$1." rwsai

              If like me, you have difficulty remembering the syntax for the four
              lookaround cases.
              (?=positive_lookahead)
              (?!negative_lookahead)
              (?<=positive_lookbehind)
              (?<!negative_lookbehind)

              you could also do what I frequently do ... break it into two steps ...
              first to change missing and correct data, second to correct the
              over-corrections ... ie:
              ^!replace "$" >> "." rwsai ;--- adds period to EVERY line
              ^!replace "\.\.$" >> "." rwsai ;--- removes a double period at end of
              line

              all three of the above methods will put a period on empty or blank_only
              (or blank_tab_only if present) lines.

              If you don't want periods in this case as Sheri's suggestion handled,
              add this extra line to whichever of the three you chose
              ^!replace "^\s*\.$" >> "" rwsai

              In many cases its *is* possible to come up with a one-liner at the
              expense of obviousness and readability but its not always (IMO) wise to
              do so in case you or someone else will need to figure out after the fact
              what was being done.

              --
              Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)




              [Non-text portions of this message have been removed]
            • John Shotsky
              Many thanks to you and the others! This gives me some more needed training in the finer points. I tend to bull my way through to get results I want, then go
              Message 6 of 23 , Apr 6, 2009
              • 0 Attachment
                Many thanks to you and the others!



                This gives me some more needed training in the finer points. I tend to bull my way through to
                get results I want, then go back and neaten things up later. This is one where I have been
                letting it make errors, then clean them up with another clip. I realize that makes the clips
                take more time, which is one reason for wanting to only make changes that are necessary.



                ;I document a lot.

                ;Just in case I need to come back to edit.. J



                I will play around with these suggestions to see which ones execute fastest and most accurately.
                Usually, after I dissect an example, it dawns on me what the documentation was trying to say. My
                master clip library is now over 7200 lines, so it is a very busy clip library, indeed. Any
                improvements in accuracy and/or speed are appreciated.



                John



                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Alec Burgess
                Sent: Monday, April 06, 2009 6:04 PM
                To: ntb-clips@yahoogroups.com
                Subject: Re: [Clip] Re: Handling periods at ends of lines




                John Shotsky (jshotsky@... <mailto:jshotsky%40comcast.net> ) wrote (in part) (on
                2009-04-06 at
                18:25):
                >
                > PS: Oddly enough, as I was playing with it some more, I found the
                > magic solution: 1 measly
                > question mark makes it work correctly.
                >
                > ^!Replace "^(This is an example line.+?)\.?\R" >> "$1\.\n" ARSTW

                beating the dead horse department ....

                Hi John:
                The "cleanest" way to do it is with a negative lookbehind:
                ^!replace "(?m)(?<!\.)$" >> "." rwsai
                (?m) forces ^ and $ to match at linebreaks ... not really needed since
                that is the default in Notetab 5
                (?<!\.) is negative lookbehind

                Another way is:
                ^!replace "(?m)([^\.])$" >> "$1." rwsai

                If like me, you have difficulty remembering the syntax for the four
                lookaround cases.
                (?=positive_lookahead)
                (?!negative_lookahead)
                (?<=positive_lookbehind)
                (?<!negative_lookbehind)

                you could also do what I frequently do ... break it into two steps ...
                first to change missing and correct data, second to correct the
                over-corrections ... ie:
                ^!replace "$" >> "." rwsai ;--- adds period to EVERY line
                ^!replace "\.\.$" >> "." rwsai ;--- removes a double period at end of
                line

                all three of the above methods will put a period on empty or blank_only
                (or blank_tab_only if present) lines.

                If you don't want periods in this case as Sheri's suggestion handled,
                add this extra line to whichever of the three you chose
                ^!replace "^\s*\.$" >> "" rwsai

                In many cases its *is* possible to come up with a one-liner at the
                expense of obviousness and readability but its not always (IMO) wise to
                do so in case you or someone else will need to figure out after the fact
                what was being done.

                --
                Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)

                [Non-text portions of this message have been removed]





                [Non-text portions of this message have been removed]
              • John Shotsky
                Flo, This indeed works, but I don t understand what the (?!.) term does. Can you elaborate? Thanks! John From: ntb-clips@yahoogroups.com
                Message 7 of 23 , Apr 6, 2009
                • 0 Attachment
                  Flo,



                  This indeed works, but I don't understand what the (?!.) term does. Can you elaborate?



                  Thanks!

                  John



                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Flo
                  Sent: Monday, April 06, 2009 5:44 PM
                  To: ntb-clips@yahoogroups.com
                  Subject: [Clip] Re: Handling periods at ends of lines



                  --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky"
                  <jshotsky@...> wrote:
                  >
                  > I really need it to work on the whole document, finding only
                  > the lines specified in the find part of the command.
                  > I'm reasonably certain it can be done using a replace statement
                  > such as I am using (so I can control what is found), but with some
                  > element that prevents the double periods.

                  Try this (corrected -- sorry!)...

                  ^!Replace "^(This is an example line[^.\r\n]*)(?!.)" >> "$1." AWRS

                  Flo





                  [Non-text portions of this message have been removed]
                • Flo
                  ... Negative Lookahead, i.e. string must not be followed by a dot. Or more exactly: Matches at a position where you don t see a dot when looking ahead. Flo
                  Message 8 of 23 , Apr 6, 2009
                  • 0 Attachment
                    --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
                    >
                    > Flo,
                    >
                    > This indeed works, but I don't understand what the (?!.) term does.
                    > Can you elaborate?

                    Negative Lookahead, i.e. string must not be followed by a dot. Or more exactly: Matches at a position where you don't see a dot when looking ahead.

                    Flo
                  • Flo
                    ... So it must be... ^!Replace ^(This is an example line[^. r n]*)(?! .) $1. AWRS of course. Sorry again -- it s been a very long day. I better go to
                    Message 9 of 23 , Apr 6, 2009
                    • 0 Attachment
                      --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
                      >
                      > --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@> wrote:
                      > >
                      > > Flo,
                      > >
                      > > This indeed works, but I don't understand what the (?!.) term does.
                      > > Can you elaborate?
                      >
                      > Negative Lookahead, i.e. string must not be followed by a dot.

                      So it must be...

                      ^!Replace "^(This is an example line[^.\r\n]*)(?!\.)" >> "$1." AWRS

                      of course. Sorry again -- it's been a very long day. I better go to bed now...

                      Flo
                    • John Shotsky
                      Flo, Thank you, I get that now. I assume that since it will only match when a period is not on the end of the found line, that it will execute substantially
                      Message 10 of 23 , Apr 6, 2009
                      • 0 Attachment
                        Flo,

                        Thank you, I get that now. I assume that since it will only match when a period is not on the
                        end of the 'found' line, that it will execute substantially faster than one that finds each
                        line, period or not, as my example does. If that is the case, I can see that I might speed up my
                        overall time through this technique. Some of my documents have thousands of lines, and at least
                        one has over 60,000 lines.I'll time this to see what the difference is.



                        Thanks again!

                        John



                        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Flo
                        Sent: Monday, April 06, 2009 7:42 PM
                        To: ntb-clips@yahoogroups.com
                        Subject: [Clip] Re: Handling periods at ends of lines



                        --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky"
                        <jshotsky@...> wrote:
                        >
                        > Flo,
                        >
                        > This indeed works, but I don't understand what the (?!.) term does.
                        > Can you elaborate?

                        Negative Lookahead, i.e. string must not be followed by a dot. Or more exactly: Matches at a
                        position where you don't see a dot when looking ahead.

                        Flo





                        [Non-text portions of this message have been removed]
                      • John Shotsky
                        Thank you again, I was still missing how the dot was working when looking at the clip and looking at my sample. It worked on my sample without the .
                        Message 11 of 23 , Apr 6, 2009
                        • 0 Attachment
                          Thank you again, I was still missing how the dot was working when looking at the clip and
                          looking at my sample. It worked on my sample without the \. surprisingly. So wouldn't the
                          replace actually be $1\. too?



                          In fact, this one doesn't work, while the first one did. Here are my example lines again:

                          This is an example line without a period

                          This is an example line with a period.



                          The first clip puts a period where it is needed, the second one produces this:

                          This is an example line without a period.

                          This is an example line with a perio.d.



                          I'm confused.the whole assertion thing is new to me.



                          No rush, get your sleep.and thanks again!

                          John



                          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Flo
                          Sent: Monday, April 06, 2009 7:57 PM
                          To: ntb-clips@yahoogroups.com
                          Subject: [Clip] Re: Handling periods at ends of lines



                          --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "Flo" <flo.gehrke@...>
                          wrote:
                          >
                          > --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky"
                          <jshotsky@> wrote:
                          > >
                          > > Flo,
                          > >
                          > > This indeed works, but I don't understand what the (?!.) term does.
                          > > Can you elaborate?
                          >
                          > Negative Lookahead, i.e. string must not be followed by a dot.

                          So it must be...

                          ^!Replace "^(This is an example line[^.\r\n]*)(?!\.)" >> "$1." AWRS

                          of course. Sorry again -- it's been a very long day. I better go to bed now...

                          Flo





                          [Non-text portions of this message have been removed]
                        • Sheri
                          ... I misunderstood, thought you wanted to confine it to selected lines. All you would have needed to do is use only the replace command from the above, and
                          Message 12 of 23 , Apr 6, 2009
                          • 0 Attachment
                            --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
                            >
                            > Thanks Sheri, but I really need it to work on the whole document,
                            > finding only the lines specified in the find part of the command.
                            > My documents have thousands of lines, and only a few need to be
                            > changed. Essentially, I am looking for sentences that have lost
                            > or were never given a period, but there are many more lines that
                            > are not sentences and should never get a period added.
                            >
                            > --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky"
                            > <jshotsky@> wrote:
                            > >
                            > > I want to find certain lines and add a period only if there isn't
                            > > one already. If there is already a period, I want to leave it,
                            > > but if there is not one, I want to add one. It would be ok to
                            > > remove an existing one and replace it with a new one, of course.
                            > > But it has to work only on the lines I search on.
                            >
                            > Try it this way, untested but should work:
                            >
                            > ^!IfFalse ^$GetSelSize$ Next Else Skip_2
                            > ^!Prompt This clip requires a selection.
                            > ^!Goto End
                            > ^!Replace "[^\r\n.]\K$" >> "." RAHS
                            >

                            I misunderstood, thought you wanted to confine it to selected lines. All you would have needed to do is use only the replace command from the above, and put the cursor at the top of the file. Or change the H in options to a W, in which case it would always search from the top of the file through the whole document.

                            Regards,
                            Sheri
                          • Vance E. Neff
                            Hi, For some reason the following clip seems to stop prematurely, but NoteTab is still doing something in the back ground. CPU usage is at %100. Plus, when I
                            Message 13 of 23 , Apr 7, 2009
                            • 0 Attachment
                              Hi,

                              For some reason the following clip seems to stop prematurely, but
                              NoteTab is still doing something in the back ground. CPU usage is at
                              %100. Plus, when I exit NoteTab, it seems to exit but the process is
                              still running at %100.

                              All this clip does is insert an If/Endif level indicator before each line.

                              Heres the clip:
                              ;^!setdebug ON
                              ^!Info Insert IF/ELSE rank levels
                              ;^!ToolBar New Document
                              ;^!SetFocus Frame2
                              ^!Jump TEXT_START
                              ^!Set %IfLevel%=0
                              ;^!SetScreenUpdate Off
                              :StartLoop
                              ^!Keyboard HOME
                              ^!Select LINE
                              :CheckForIf
                              ^!Find "^[\s\t]*if[\s\t]" ishr
                              ^!IfError CheckForEndif
                              :FoundIf
                              ^!Inc %IfLevel%
                              ^!Select LINE
                              ^!GoTo RankThisLine
                              :CheckForEndif
                              ^!Find "^[\s\t]*endif" ishr
                              ^!IfError RankThisLine
                              ^!Select LINE
                              :FoundEndif
                              ^!Dec %IfLevel%
                              :RankThisLine
                              ;^!Set %Line%=^$GetSelection$
                              ;^!SetFocus Frame1
                              ;^!Insert "^%IfLevel% ^%Line%"
                              ;^!SetFocus Frame2
                              ^!Keyboard up HOME
                              ^!Insert "^%IfLevel% "
                              ^!Find "^P" s
                              ^!IfError EndScan
                              ^!Goto StartLoop
                              :EndScan
                              ^!SetFocus Frame1

                              Any ideas?

                              Thanks,
                              Vance
                            • Don - HtmlFixIt.com
                              Well without a sample of before and after it s a bit vague. I don t completely understand what we are doing even. My first comment would be to get rid of all
                              Message 14 of 23 , Apr 7, 2009
                              • 0 Attachment
                                Well without a sample of before and after it's a bit vague. I don't
                                completely understand what we are doing even.

                                My first comment would be to get rid of all keyboard commands if there
                                is an equivalent non-keyboard ...
                                example the home keyboard can be replaced by a jump doc start command.
                                That will be more efficient every time Vance.

                                Don

                                Vance E. Neff wrote:
                                > Hi,
                                >
                                > For some reason the following clip seems to stop prematurely, but
                                > NoteTab is still doing something in the back ground. CPU usage is at
                                > %100. Plus, when I exit NoteTab, it seems to exit but the process is
                                > still running at %100.
                                >
                                > All this clip does is insert an If/Endif level indicator before each line.
                                >
                                > Heres the clip:
                                > ;^!setdebug ON
                                > ^!Info Insert IF/ELSE rank levels
                                > ;^!ToolBar New Document
                                > ;^!SetFocus Frame2
                                > ^!Jump TEXT_START
                                > ^!Set %IfLevel%=0
                                > ;^!SetScreenUpdate Off
                                > :StartLoop
                                > ^!Keyboard HOME
                                > ^!Select LINE
                                > :CheckForIf
                                > ^!Find "^[\s\t]*if[\s\t]" ishr
                                > ^!IfError CheckForEndif
                                > :FoundIf
                                > ^!Inc %IfLevel%
                                > ^!Select LINE
                                > ^!GoTo RankThisLine
                                > :CheckForEndif
                                > ^!Find "^[\s\t]*endif" ishr
                                > ^!IfError RankThisLine
                                > ^!Select LINE
                                > :FoundEndif
                                > ^!Dec %IfLevel%
                                > :RankThisLine
                                > ;^!Set %Line%=^$GetSelection$
                                > ;^!SetFocus Frame1
                                > ;^!Insert "^%IfLevel% ^%Line%"
                                > ;^!SetFocus Frame2
                                > ^!Keyboard up HOME
                                > ^!Insert "^%IfLevel% "
                                > ^!Find "^P" s
                                > ^!IfError EndScan
                                > ^!Goto StartLoop
                                > :EndScan
                                > ^!SetFocus Frame1
                                >
                                > Any ideas?
                                >
                                > Thanks,
                                > Vance
                                >
                                >
                                >
                                > ------------------------------------
                                >
                                > Fookes Software: http://www.fookes.com/
                                > NoteTab website: http://www.notetab.com/
                                > NoteTab Discussion Lists: http://www.notetab.com/groups.php
                                >
                                > ***
                                > Yahoo! Groups Links
                                >
                                >
                                >
                                >
                              • Flo
                                ... John, Let me first try again to clear the job you want to do. My test lines are... This is an example line without a period Another line with a period.
                                Message 15 of 23 , Apr 7, 2009
                                • 0 Attachment
                                  --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
                                  >
                                  > Thank you again, I was still missing how the dot was working when
                                  > looking at the clip and looking at my sample....

                                  John,

                                  Let me first try again to clear the job you want to do.

                                  My test lines are...

                                  This is an example line without a period
                                  Another line with a period.
                                  This is an example line with a period.
                                  Another line without a period
                                  This is an example line without a period

                                  I understand that you want to add a period to line #1 and #5 only. That is, to lines which (a) contain the sample string "This is an example line", and which (b) don't end with a period.

                                  So here's another proposal which combines Sheri's approach with the sample string...

                                  ^!Replace "^(This is an example line.*)[^\r\n.]\K$" >> "." AWRS

                                  It adds a period to line #1 and #5 only. The rest is ignored. Is this the job you want to do?

                                  Maybe I misunderstood the whole issue and you want to add a period to ANY line that doesn't end with a period. In this case, Sheri's proposal...

                                  ^!Replace "[^\r\n.]\K$" >> "." AWRS

                                  would the job, of course.

                                  Flo


                                  P.S. to Alec:

                                  Your first solution (without ?m)...

                                  ^!replace "(?<!\.)$" >> "." rwsai

                                  works fine for me too. Since it adds a period to ANY line that doesn't end with a period it possibly doesn't meet the job (matching that sample string) (??)

                                  > Another way is:
                                  > ^!replace "(?m)([^\.])$" >> "$1." rwsai

                                  This doesn't work for me. It "splits" the CRNL at the end of each line because, with [^\.], also the CR is matched. So, at the end of line #1 to #4, we get ".CR.CRNL".

                                  By the way: We don't have to escape the dot here -- inside a character class, it's always regarded as a literal dot.
                                   
                                • Vance E. Neff
                                  Don, Thanks, for some reason that fixed it. I ll attempt to keep away from ^!Keyboard commands in the future. Vance
                                  Message 16 of 23 , Apr 7, 2009
                                  • 0 Attachment
                                    Don,

                                    Thanks, for some reason that fixed it. I'll attempt to keep away from
                                    ^!Keyboard commands in the future.

                                    Vance

                                    Don - HtmlFixIt.com wrote:
                                    > Well without a sample of before and after it's a bit vague. I don't
                                    > completely understand what we are doing even.
                                    >
                                    > My first comment would be to get rid of all keyboard commands if there
                                    > is an equivalent non-keyboard ...
                                    > example the home keyboard can be replaced by a jump doc start command.
                                    > That will be more efficient every time Vance.
                                    >
                                    > Don
                                    >
                                    > Vance E. Neff wrote:
                                    >> Hi,
                                    >>
                                    >> For some reason the following clip seems to stop prematurely, but
                                    >> NoteTab is still doing something in the back ground. CPU usage is at
                                    >> %100. Plus, when I exit NoteTab, it seems to exit but the process is
                                    >> still running at %100.
                                    >>
                                    >> All this clip does is insert an If/Endif level indicator before each line.
                                    >>
                                    >> Heres the clip:
                                    >> ;^!setdebug ON
                                    >> ^!Info Insert IF/ELSE rank levels
                                    >> ;^!ToolBar New Document
                                    >> ;^!SetFocus Frame2
                                    >> ^!Jump TEXT_START
                                    >> ^!Set %IfLevel%=0
                                    >> ;^!SetScreenUpdate Off
                                    >> :StartLoop
                                    >> ^!Keyboard HOME
                                    >> ^!Select LINE
                                    >> :CheckForIf
                                    >> ^!Find "^[\s\t]*if[\s\t]" ishr
                                    >> ^!IfError CheckForEndif
                                    >> :FoundIf
                                    >> ^!Inc %IfLevel%
                                    >> ^!Select LINE
                                    >> ^!GoTo RankThisLine
                                    >> :CheckForEndif
                                    >> ^!Find "^[\s\t]*endif" ishr
                                    >> ^!IfError RankThisLine
                                    >> ^!Select LINE
                                    >> :FoundEndif
                                    >> ^!Dec %IfLevel%
                                    >> :RankThisLine
                                    >> ;^!Set %Line%=^$GetSelection$
                                    >> ;^!SetFocus Frame1
                                    >> ;^!Insert "^%IfLevel% ^%Line%"
                                    >> ;^!SetFocus Frame2
                                    >> ^!Keyboard up HOME
                                    >> ^!Insert "^%IfLevel% "
                                    >> ^!Find "^P" s
                                    >> ^!IfError EndScan
                                    >> ^!Goto StartLoop
                                    >> :EndScan
                                    >> ^!SetFocus Frame1
                                    >>
                                    >> Any ideas?
                                    >>
                                    >> Thanks,
                                    >> Vance
                                    >>
                                    >>
                                    >>
                                    >> ------------------------------------
                                    >>
                                    >> Fookes Software: http://www.fookes.com/
                                    >> NoteTab website: http://www.notetab.com/
                                    >> NoteTab Discussion Lists: http://www.notetab.com/groups.php
                                    >>
                                    >> ***
                                    >> Yahoo! Groups Links
                                    >>
                                    >>
                                    >>
                                    >>
                                    >
                                    >
                                    >
                                    > ------------------------------------
                                    >
                                    > Fookes Software: http://www.fookes.com/
                                    > NoteTab website: http://www.notetab.com/
                                    > NoteTab Discussion Lists: http://www.notetab.com/groups.php
                                    >
                                    > ***
                                    > Yahoo! Groups Links
                                    >
                                    >
                                    >
                                    >
                                    >
                                  • Don - HtmlFixIt.com
                                    ... Keyboard commands add timing into the equation ... the command takes a keyboard stroke figuratively and so they vary with the speed of your processor.
                                    Message 17 of 23 , Apr 7, 2009
                                    • 0 Attachment
                                      Vance E. Neff wrote:
                                      > Don,
                                      >
                                      > Thanks, for some reason that fixed it. I'll attempt to keep away from
                                      > ^!Keyboard commands in the future.
                                      >
                                      > Vance
                                      Keyboard commands add timing into the equation ... the command takes a
                                      keyboard stroke figuratively and so they vary with the speed of your
                                      processor. Most any other command executes fully before moving on, but
                                      a keyboard command only send the message to "stroke" the keyboard
                                      essentially. So in this case, you may have had a command executing
                                      prematurely because the keyboard stroke had not occurred even though it
                                      was in process.

                                      Often if you add keyboard strokes, it is worthwhile to add a delay
                                      following them to be sure the computer actually received the stroke
                                      before moving on. However there can be problems with timing just moving
                                      from one machine to another in that one may require more delay than another.

                                      Always best to avoid keyboard commands when not needed.
                                    • Vance E. Neff
                                      Hello, I am havng problems getting ^$GetDocIndex()$ to work. The statement I am using is: ^!SetDocIndex ^$GetDocIndex(cncjobsmisc.pm)$ it always resolves to:
                                      Message 18 of 23 , Apr 9, 2009
                                      • 0 Attachment
                                        Hello,

                                        I am havng problems getting ^$GetDocIndex()$ to work.

                                        The statement I am using is:
                                        ^!SetDocIndex ^$GetDocIndex(cncjobsmisc.pm)$
                                        it always resolves to:
                                        ^!SetDocIndex 0

                                        I tried quotes and assigning the document name to a variable with the
                                        same results.
                                        What am I doing wrong?

                                        Vance
                                      • Sheri
                                        ... You might try running this clip while cncjobsmisc.pm is the active document; it will give you the full document name. ^!Info ^$GetDocName()$ You can copy
                                        Message 19 of 23 , Apr 9, 2009
                                        • 0 Attachment
                                          --- In ntb-clips@yahoogroups.com, "Vance E. Neff" <veneff@...> wrote:
                                          >
                                          > Hello,
                                          >
                                          > I am havng problems getting ^$GetDocIndex()$ to work.
                                          >
                                          > The statement I am using is:
                                          > ^!SetDocIndex ^$GetDocIndex(cncjobsmisc.pm)$
                                          > it always resolves to:
                                          > ^!SetDocIndex 0
                                          >
                                          > I tried quotes and assigning the document name to a variable with the
                                          > same results.
                                          > What am I doing wrong?
                                          >
                                          > Vance
                                          >

                                          You might try running this clip while cncjobsmisc.pm is the active document; it will give you the full document name.

                                          ^!Info ^$GetDocName()$

                                          You can copy the full name from the info popup, and paste it into your getdocindex function. I would put the name in double quotes, e.g.,

                                          ^!SetDocIndex ^$GetDocIndex("C:\Test Docs\cncjobsmisc.pm")$

                                          Regards,
                                          Sheri
                                        • Vance E. Neff
                                          Sheri, Thanks, it never occurred to me that the path was required as part of the name, though it does make sense that it is. Thanks again! Vance
                                          Message 20 of 23 , Apr 9, 2009
                                          • 0 Attachment
                                            Sheri,

                                            Thanks, it never occurred to me that the path was required as part of
                                            the name, though it does make sense that it is.

                                            Thanks again!
                                            Vance

                                            Sheri wrote:
                                            > --- In ntb-clips@yahoogroups.com, "Vance E. Neff" <veneff@...> wrote:
                                            >> Hello,
                                            >>
                                            >> I am havng problems getting ^$GetDocIndex()$ to work.
                                            >>
                                            >> The statement I am using is:
                                            >> ^!SetDocIndex ^$GetDocIndex(cncjobsmisc.pm)$
                                            >> it always resolves to:
                                            >> ^!SetDocIndex 0
                                            >>
                                            >> I tried quotes and assigning the document name to a variable with the
                                            >> same results.
                                            >> What am I doing wrong?
                                            >>
                                            >> Vance
                                            >>
                                            >
                                            > You might try running this clip while cncjobsmisc.pm is the active document; it will give you the full document name.
                                            >
                                            > ^!Info ^$GetDocName()$
                                            >
                                            > You can copy the full name from the info popup, and paste it into your getdocindex function. I would put the name in double quotes, e.g.,
                                            >
                                            > ^!SetDocIndex ^$GetDocIndex("C:\Test Docs\cncjobsmisc.pm")$
                                            >
                                            > Regards,
                                            > Sheri
                                            >
                                            >
                                            >
                                            > ------------------------------------
                                            >
                                            > Fookes Software: http://www.fookes.com/
                                            > NoteTab website: http://www.notetab.com/
                                            > NoteTab Discussion Lists: http://www.notetab.com/groups.php
                                            >
                                            > ***
                                            > Yahoo! Groups Links
                                            >
                                            >
                                            >
                                            >
                                            >
                                          • Sheri
                                            ... Hi Flo, Seems I m guilty of not reading the notes very closely, and looking only at the original sample, which sadly did not include any lines that
                                            Message 21 of 23 , Apr 9, 2009
                                            • 0 Attachment
                                              Flo wrote:
                                              > --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
                                              >
                                              >> Thank you again, I was still missing how the dot was working when
                                              >> looking at the clip and looking at my sample....
                                              >>
                                              >
                                              > John,
                                              >
                                              > Let me first try again to clear the job you want to do.
                                              >
                                              > My test lines are...
                                              >
                                              > This is an example line without a period
                                              > Another line with a period.
                                              > This is an example line with a period.
                                              > Another line without a period
                                              > This is an example line without a period
                                              >
                                              > I understand that you want to add a period to line #1 and #5 only. That is, to lines which (a) contain the sample string "This is an example line", and which (b) don't end with a period.
                                              >
                                              > So here's another proposal which combines Sheri's approach with the sample string...
                                              >
                                              > ^!Replace "^(This is an example line.*)[^\r\n.]\K$" >> "." AWRS
                                              >
                                              > It adds a period to line #1 and #5 only. The rest is ignored. Is this the job you want to do?
                                              >
                                              > Maybe I misunderstood the whole issue and you want to add a period to ANY line that doesn't end with a period. In this case, Sheri's proposal...
                                              >
                                              > ^!Replace "[^\r\n.]\K$" >> "." AWRS
                                              >
                                              > would the job, of course.
                                              >
                                              > Flo
                                              >
                                              >
                                              Hi Flo,

                                              Seems I'm guilty of not reading the notes very closely, and looking only
                                              at the original sample, which sadly did not include any lines that
                                              shouldn't be altered. I was trying to help when I really didn't have
                                              time to scrutinize the messages.

                                              Now I see that he did say: "there are many [...] lines that are not
                                              sentences and should never get a period added"

                                              Regards,
                                              Sheri
                                            • Don Daugherty
                                              ... I think you need to include the full path with the name, e.g., ^$GetDocIndex(c: My Documents cncjobmisc.pm)$ It seems to work fine with or without quotes
                                              Message 22 of 23 , Apr 9, 2009
                                              • 0 Attachment
                                                Vance E. Neff wrote:
                                                > Hello,
                                                >
                                                > I am havng problems getting ^$GetDocIndex()$ to work.
                                                >
                                                > The statement I am using is:
                                                > ^!SetDocIndex ^$GetDocIndex(cncjobsmisc.pm)$
                                                > it always resolves to:
                                                > ^!SetDocIndex 0
                                                >
                                                > I tried quotes and assigning the document name to a variable with the
                                                > same results.
                                                > What am I doing wrong?
                                                >
                                                > Vance
                                                >
                                                I think you need to include the full path with the name, e.g.,
                                                ^$GetDocIndex(c:\My Documents\cncjobmisc.pm)$

                                                It seems to work fine with or without quotes inside the parentheses.
                                              • John Shotsky
                                                Flo, Yes, you have interpreted my requirements correctly. Also, your clip does it as needed. I would never have come up with that on my own. It ll be worked
                                                Message 23 of 23 , Apr 9, 2009
                                                • 0 Attachment
                                                  Flo,



                                                  Yes, you have interpreted my requirements correctly. Also, your clip does it as needed. I would never have come up with
                                                  that on my own. It'll be worked into my clip library in several places.



                                                  I didn't know the dot was considered literally inside a character class.that probably explains why some of my previous
                                                  clips didn't work as I expected. (I usually try things quite a few ways before I ask for help.). Also, when searching
                                                  for line ends, I almost always use \R, which matches any kind of line end. If I'm replacing, I use \n as the
                                                  replacement.



                                                  Sorry to be late in answering - I contracted a virus 'HACKTOOL' from a web site, and it took out my boot drive. I wasn't
                                                  even doing anything, but up came a blue screen of death, computer halted, then wouldn't boot again. I've spent the last
                                                  couple days rebuilding from scratch almost. Yes, I ordinarily run virus software all the time, but I had just rebuilt
                                                  this system and was waiting for my Norton antivirus software to arrive, so I was browsing the internet using only sites
                                                  that I'd been to before safely. Unfortunately, one of them now slips you HACKTOOL when you visit. In case any of you
                                                  have been browsing for graphic/image utilities, don't even think about visiting wwwdotbrothersoftdotcom.



                                                  John



                                                  From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Flo
                                                  Sent: Tuesday, April 07, 2009 9:17 AM
                                                  To: ntb-clips@yahoogroups.com
                                                  Subject: [Clip] Re: Handling periods at ends of lines



                                                  --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
                                                  >
                                                  > Thank you again, I was still missing how the dot was working when
                                                  > looking at the clip and looking at my sample....

                                                  John,

                                                  Let me first try again to clear the job you want to do.

                                                  My test lines are...

                                                  This is an example line without a period
                                                  Another line with a period.
                                                  This is an example line with a period.
                                                  Another line without a period
                                                  This is an example line without a period

                                                  I understand that you want to add a period to line #1 and #5 only. That is, to lines which (a) contain the sample string
                                                  "This is an example line", and which (b) don't end with a period.

                                                  So here's another proposal which combines Sheri's approach with the sample string...

                                                  ^!Replace "^(This is an example line.*)[^\r\n.]\K$" >> "." AWRS

                                                  It adds a period to line #1 and #5 only. The rest is ignored. Is this the job you want to do?

                                                  Maybe I misunderstood the whole issue and you want to add a period to ANY line that doesn't end with a period. In this
                                                  case, Sheri's proposal...

                                                  ^!Replace "[^\r\n.]\K$" >> "." AWRS

                                                  would the job, of course.

                                                  Flo

                                                  P.S. to Alec:

                                                  Your first solution (without ?m)...

                                                  ^!replace "(?<!\.)$" >> "." rwsai

                                                  works fine for me too. Since it adds a period to ANY line that doesn't end with a period it possibly doesn't meet the
                                                  job (matching that sample string) (??)

                                                  > Another way is:
                                                  > ^!replace "(?m)([^\.])$" >> "$1." rwsai

                                                  This doesn't work for me. It "splits" the CRNL at the end of each line because, with [^\.], also the CR is matched. So,
                                                  at the end of line #1 to #4, we get ".CR.CRNL".

                                                  By the way: We don't have to escape the dot here -- inside a character class, it's always regarded as a literal dot.






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