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

[Clip] Re: Handling periods at ends of lines

Expand Messages
  • 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 1 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 2 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 3 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 4 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 5 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 6 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 7 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 8 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 9 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 10 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 11 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 12 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.