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

Using toolbar on multiple, separated lines

Expand Messages
  • John Shotsky
    I m looking for a way to use the toolbar sentence case command on selected, but separate lines in a a file. Let s just say every line is upper case, is
    Message 1 of 12 , Jan 26, 2014
    • 0 Attachment

      I'm looking for a way to use the toolbar 'sentence case' command on selected, but separate lines in a a file. Let's just say every line is upper case, is numbered 1-9, and for each line numbered 1, I want to sentence case ALL of them, using ONE command. I realize this is probably not possible, but thought I'd ask. I was thinking the doclist command, maybe in some way. I know how to do it using a 'Find' and a loop to do it, but I didn't want to operate the toolbar command on 1000 lines when it might be possible to do it just once.

      Any ideas?

       

      Regards,
      John

       

    • Alec Burgess
      John - its not clear whether all the 1 lines are together (ie. file is sorted or can be sorted and left that way) For now - assume yes ... (1) use a regex to
      Message 2 of 12 , Jan 26, 2014
      • 0 Attachment
        John - its not clear whether all the '1' lines are together (ie. file is sorted or can be sorted and left that way)
        For now - assume yes ...
        (1) use a regex to change all \R to any unique string not present in input data resulting in a single line (say ####)
        (2) Select the line and set sentence case Shift+Ctrl+U or in a clip
        -- ^!Menu Modify/"Text case"/Sentence
        (3) Change all the #### back to \r\n

        If not yes above before (1) use ^!Menu Lines\"Number lines" then a clip replace to swap the line number and the line id and sort ascending then steps 1 to 3 above

        After step 3 to recover original order re-swap line-id and line number, sort ascending and use a regex to remove the line numbers.

        Note: AFAICT the Number lines step requires an [OK] or entry of a line number followed by [OK]. As it happens, the Sample code library contains a Perl numLines script if you want no keyboard entry.
        @anyone - is there any clip commands that avoids the manual entry for ^!Menu Lines\"Number lines"?


        On 2014-01-26 19:22, John Shotsky wrote:
        I'm looking for a way to use the toolbar 'sentence case' command on selected, but separate lines in a a file. Let's just say every line is upper case, is numbered 1-9, and for each line numbered 1, I want to sentence case ALL of them, using ONE command. I realize this is probably not possible, but thought I'd ask. I was thinking the doclist command, maybe in some way. I know how to do it using a 'Find' and a loop to do it, but I didn't want to operate the toolbar command on 1000 lines when it might be possible to do it just once.

        --
        Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)
      • Dave
        Hi what about ^$GetDocMatchAll( Pattern [;SubPatternId])$ might be worth looking at. THANKYOU DAVE-M ... From: John Shotsky To: ntb-clips@yahoogroups.com Sent:
        Message 3 of 12 , Jan 27, 2014
        • 0 Attachment
          Hi
          what about ^$GetDocMatchAll("Pattern"[;SubPatternId])$ might be worth looking at.
              THANKYOU DAVE-M
          ----- Original Message -----
          Sent: Monday, January 27, 2014 11:22 AM
          Subject: [Clip] Using toolbar on multiple, separated lines

          I'm looking for a way to use the toolbar 'sentence case' command on selected, but separate lines in a a file. Let's just say every line is upper case, is numbered 1-9, and for each line numbered 1, I want to sentence case ALL of them, using ONE command. I realize this is probably not possible, but thought I'd ask. I was thinking the doclist command, maybe in some way. I know how to do it using a 'Find' and a loop to do it, but I didn't want to operate the toolbar command on 1000 lines when it might be possible to do it just once.

          Any ideas?

           

          Regards,
          John

           

        • John Shotsky
          The line order cannot be changed, and every 1 is separated from every other 1 by 9 lines. Think of it as 1000 lines numbered 1-1000, and we want to lower
          Message 4 of 12 , Jan 27, 2014
          • 0 Attachment

            The line order cannot be changed, and every '1' is separated from every other '1' by 9 lines. Think of it as 1000 lines numbered 1-1000, and we want to lower case only the ones whose line number ends with '0'. I don’t' need logic to figure out which ones need changing, I need to understand it is possible to select those 100 lines at one time, and use the toolbar on them, (or any other method that doesn't require a find/loop.)

            The simplest test case would be two lines starting with 1, separated by one line starting with 2. Change those two lines with one command, not a loop.

            Regards,
            John
            RecipeTools Web Site: http://recipetools.gotdns.com/
            John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

             

            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Alec Burgess
            Sent: Sunday, January 26, 2014 20:53
            To: ntb-clips@yahoogroups.com
            Subject: Re: [Clip] Using toolbar on multiple, separated lines

             

             

            John - its not clear whether all the '1' lines are together (ie. file is sorted or can be sorted and left that way)
            For now - assume yes ...
            (1) use a regex to change all \R to any unique string not present in input data resulting in a single line (say ####)
            (2) Select the line and set sentence case Shift+Ctrl+U or in a clip
            -- ^!Menu Modify/"Text case"/Sentence
            (3) Change all the #### back to \r\n

            If not yes above before (1) use ^!Menu Lines\"Number lines" then a clip replace to swap the line number and the line id and sort ascending then steps 1 to 3 above

            After step 3 to recover original order re-swap line-id and line number, sort ascending and use a regex to remove the line numbers.

            Note: AFAICT the Number lines step requires an [OK] or entry of a line number followed by [OK]. As it happens, the Sample code library contains a Perl numLines script if you want no keyboard entry.
            @anyone - is there any clip commands that avoids the manual entry for ^!Menu Lines\"Number lines"?


            On 2014-01-26 19:22, John Shotsky wrote:

            I'm looking for a way to use the toolbar 'sentence case' command on selected, but separate lines in a a file. Let's just say every line is upper case, is numbered 1-9, and for each line numbered 1, I want to sentence case ALL of them, using ONE command. I realize this is probably not possible, but thought I'd ask. I was thinking the doclist command, maybe in some way. I know how to do it using a 'Find' and a loop to do it, but I didn't want to operate the toolbar command on 1000 lines when it might be possible to do it just once.

             

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

          • Axel Berger
            ... Why on earth not? That was just what I was going to suggest. ^!InsertText ^$StrSentenceCase( ^$GetSelection$ )$ Axel
            Message 5 of 12 , Jan 27, 2014
            • 0 Attachment
              John Shotsky wrote:
              > or any other method that doesn't require a find/loop.

              Why on earth not? That was just what I was going to suggest.

              ^!InsertText ^$StrSentenceCase("^$GetSelection$")$

              Axel
            • John Shotsky
              Because I already know how to do that. That is what I want to replace. One command rather than 1000 loops. Besides, InsertText is awfully slow by itself.
              Message 6 of 12 , Jan 27, 2014
              • 0 Attachment

                Because I already know how to do that. That is what I want to replace. One command rather than 1000 loops. Besides, InsertText is awfully slow by itself.

                 

                Regards,
                John
                RecipeTools Web Site: http://recipetools.gotdns.com/
                John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                 

                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                Sent: Monday, January 27, 2014 08:25
                To: ntb-clips@yahoogroups.com
                Subject: Re: [Clip] Using toolbar on multiple, separated lines

                 

                 

                John Shotsky wrote:

                > or any other method that doesn't require a find/loop.

                Why on earth not? That was just what I was going to suggest.

                ^!InsertText ^$StrSentenceCase("^$GetSelection$")$

                Axel

              • flo.gehrke
                ... No, but as a work-around I use... ^!KeyboardDelay 50 ^!Keyboard CTRL+A ALT+M L N #1# ENTER BTW: In your approach, you could save yourself the numbering by
                Message 7 of 12 , Jan 29, 2014
                • 0 Attachment
                  --- In ntb-clips@yahoogroups.com, Alec Burgess <buralex@...> wrote:
                  >
                  > Note: AFAICT the Number lines step requires an [OK] or entry of
                  > a line number followed by [OK] (...)
                  > @anyone - is there any clip commands that avoids the manual
                  > entry for ^!Menu Lines\"Number lines"?

                  No, but as a work-around I use...

                  ^!KeyboardDelay 50
                  ^!Keyboard CTRL+A ALT+M L N #1# ENTER

                  BTW: In your approach, you could save yourself the numbering by executing a kind of "selective editing". Given a list like...

                  1. Apples
                  10. SENTENCE ME 1
                  2. Bananas
                  20. SENTENCE ME 2
                  3. Oranges
                  30. SENTENCE ME 3
                  4. Plums

                  The following clip will change the case in all lines where the line number ends with '0':

                  ; Mark selected lines with '@'
                  ^!Replace "^(?=\d0)" >> "@" WARS
                  ^!Set %Lines%=^$GetDocListAll("^@\K.+";"$0\r\n")$
                  ^!Toolbar New Document
                  ^%Lines%
                  ^!Select All
                  ^!Toolbar Sentence
                  ^!SetListDelimiter ^%NL%
                  ^!SetArray %SentLines%=^$GetText$
                  ^!Close Discard
                  ^!Jump Doc_Start
                  ^!Set %Id%=1

                  :Loop
                  ^!Find "^@.+$" RS
                  ^!InsertText ^%SentLines^%Id%%
                  ^!Inc %Id%
                  ^!If ^%Id% < ^%SentLines0% Loop

                  Regards,
                  Flo


                  P.S. Please note: This is a reply to Alec and not meant as a solution to John's question. IMHO, there's no way to create a "one-liner" that would do this job.
                • John Shotsky
                  Thanks, Flo, I will give this a shot and see how it stacks up time-wise. This is used to lower case ingredients in recipes, where I know where each ingredient
                  Message 8 of 12 , Jan 29, 2014
                  • 0 Attachment

                    Thanks, Flo, I will give this a shot and see how it stacks up time-wise. This is used to lower case ingredients in recipes, where I know where each ingredient section is, and they are all upper case, but if there are 100 recipes with 10 ingredients each, it makes 1000 iterations in a line-by-line basis. I can almost get a cup of coffee while this runs. I could select one whole ingredient section, then use the toolbar on that, then loop to find the next section, which should be about 10 times faster. But the fastest would be to do them at one time, which I didn't THINK was possible, but there are some pretty clever folks here, and I have seen things done that I didn't think were possible before. So, I will test both to see which is faster.

                     

                    Regards,
                    John
                    RecipeTools Web Site: http://recipetools.gotdns.com/
                    John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                     

                    From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of flo.gehrke
                    Sent: Wednesday, January 29, 2014 04:37
                    To: ntb-clips@yahoogroups.com
                    Subject: [Clip] Re: Using toolbar on multiple, separated lines

                     

                     

                    --- In ntb-clips@yahoogroups.com, Alec Burgess <buralex@...> wrote:

                    >
                    > Note: AFAICT the Number lines step requires an [OK] or entry of
                    > a line number followed by [OK] (...)
                    > @anyone - is there any clip commands that avoids the manual
                    > entry for ^!Menu Lines\"Number lines"?

                    No, but as a work-around I use...

                    ^!KeyboardDelay 50
                    ^!Keyboard CTRL+A ALT+M L N #1# ENTER

                    BTW: In your approach, you could save yourself the numbering by executing a kind of "selective editing". Given a list like...

                    1. Apples
                    10. SENTENCE ME 1
                    2. Bananas
                    20. SENTENCE ME 2
                    3. Oranges
                    30. SENTENCE ME 3
                    4. Plums

                    The following clip will change the case in all lines where the line number ends with '0':

                    ; Mark selected lines with '@'
                    ^!Replace "^(?=\d0)" >> "@" WARS
                    ^!Set %Lines%=^$GetDocListAll("^@\K.+";"$0\r\n")$
                    ^!Toolbar New Document
                    ^%Lines%
                    ^!Select All
                    ^!Toolbar Sentence
                    ^!SetListDelimiter ^%NL%
                    ^!SetArray %SentLines%=^$GetText$
                    ^!Close Discard
                    ^!Jump Doc_Start
                    ^!Set %Id%=1

                    :Loop
                    ^!Find "^@.+$" RS
                    ^!InsertText ^%SentLines^%Id%%
                    ^!Inc %Id%
                    ^!If ^%Id% < ^%SentLines0% Loop

                    Regards,
                    Flo

                    P.S. Please note: This is a reply to Alec and not meant as a solution to John's question. IMHO, there's no way to create a "one-liner" that would do this job.

                  • flo.gehrke
                    ... John, This suprises me. I take those sample lines... 1. Apples 10. SENTENCE ME 1 2. Bananas 20. SENTENCE ME 2 3. Oranges 30. SENTENCE ME 3 4. Plums and
                    Message 9 of 12 , Jan 29, 2014
                    • 0 Attachment
                      --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:

                      > This is used to lower case ingredients in recipes, where I
                      > know where each ingredient section is, and they are all
                      > upper case, but if there are 100 recipes with 10 ingredients
                      > each, it makes 1000 iterations in a line-by-line basis. I can
                      > almost get a cup of coffee while this runs...

                      John,

                      This suprises me. I take those sample lines...

                      1. Apples
                      10. SENTENCE ME 1
                      2. Bananas
                      20. SENTENCE ME 2
                      3. Oranges
                      30. SENTENCE ME 3
                      4. Plums

                      and multiply them up to 1'000 lines. Now, when running...

                      ^!SetHintInfo Working...
                      ^!SetScreenUpdate Off
                      ^!Jump Doc_Start
                      ^!Find "^\d0+.+" RS
                      ^!IfError End
                      ^!Toolbar Sentence
                      ^!Goto Skip_-3

                      against those 1'000 lines the job is done within 2 seconds. I think this isn't too slow - isn't it?

                      Regards,
                      Flo
                    • John Shotsky
                      Flo, Your example does run faster than what I had. I will have to see what causes the slowdown. When my version runs, I can watch the screen highlighting each
                      Message 10 of 12 , Jan 29, 2014
                      • 0 Attachment

                        Flo,

                        Your example does run faster than what I had. I will have to see what causes the slowdown. When my version runs, I can watch the screen highlighting each line, lower casing it, and then highlighting the next line. If it were only taking 2 seconds, it would not have been a problem. Maybe it has something to do with my data, which has many lines between sections that have to be changed. Easy enough to test variations and see which is fastest. And why.

                         

                        Regards,
                        John
                        RecipeTools Web Site: http://recipetools.gotdns.com/
                        John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                         

                        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of flo.gehrke
                        Sent: Wednesday, January 29, 2014 06:57
                        To: ntb-clips@yahoogroups.com
                        Subject: [Clip] Re: Using toolbar on multiple, separated lines

                         

                         

                        --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:

                        > This is used to lower case ingredients in recipes, where I
                        > know where each ingredient section is, and they are all
                        > upper case, but if there are 100 recipes with 10 ingredients
                        > each, it makes 1000 iterations in a line-by-line basis. I can
                        > almost get a cup of coffee while this runs...

                        John,

                        This suprises me. I take those sample lines...

                        1. Apples
                        10. SENTENCE ME 1
                        2. Bananas
                        20. SENTENCE ME 2
                        3. Oranges
                        30. SENTENCE ME 3
                        4. Plums

                        and multiply them up to 1'000 lines. Now, when running...

                        ^!SetHintInfo Working...
                        ^!SetScreenUpdate Off
                        ^!Jump Doc_Start
                        ^!Find "^\d0+.+" RS
                        ^!IfError End
                        ^!Toolbar Sentence
                        ^!Goto Skip_-3

                        against those 1'000 lines the job is done within 2 seconds. I think this isn't too slow - isn't it?

                        Regards,
                        Flo

                      • Axel Berger
                        ... More with when you looked I believe. Whenever I use a loop with InsertText it begins blazigly fast and slows down continually, so it s fine with small
                        Message 11 of 12 , Jan 29, 2014
                        • 0 Attachment
                          John Shotsky wrote:
                          > Maybe it has something to do with my data,

                          More with when you looked I believe. Whenever I use a loop with InsertText
                          it begins blazigly fast and slows down continually, so it's fine with small
                          files and becomes disproportionally slow on big ones. I have made some
                          improvements with only a single InsertText instead of several before and a
                          screen update only every hundredth loop but its still time for a coffee
                          break on my large files.

                          Axel
                        • John Shotsky
                          Ah, I knew that, but forgot. I bet that s it. Regards, John RecipeTools Web Site: http://recipetools.gotdns.com/ John s Mags
                          Message 12 of 12 , Jan 29, 2014
                          • 0 Attachment

                            Ah, I knew that, but forgot. I bet that's it.

                             

                            Regards,
                            John
                            RecipeTools Web Site: http://recipetools.gotdns.com/
                            John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

                             

                            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                            Sent: Wednesday, January 29, 2014 13:31
                            To: ntb-clips@yahoogroups.com
                            Subject: Re: [Clip] Re: Using toolbar on multiple, separated lines

                             

                             

                            John Shotsky wrote:

                            > Maybe it has something to do with my data,

                            More with when you looked I believe. Whenever I use a loop with InsertText
                            it begins blazigly fast and slows down continually, so it's fine with small
                            files and becomes disproportionally slow on big ones. I have made some
                            improvements with only a single InsertText instead of several before and a
                            screen update only every hundredth loop but its still time for a coffee
                            break on my large files.

                            Axel

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