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

Re: [Clip] Re: Adding a second when there's a tenth or more

Expand Messages
  • Axel Berger
    ... It took me some time to understand why you treat those two cases differently. It seems to me that for 09:60 your soultion will fail. Always prepending a
    Message 1 of 14 , May 24, 2013
    View Source
    • 0 Attachment
      "flo.gehrke" wrote:
      > ^!Find "([0][1-9]):60$" RS
      > ^!Find "(\d\d):60$" RS

      It took me some time to understand why you treat those two cases
      differently. It seems to me that for 09:60 your soultion will fail.
      Always prepending a leading zero and then using the rightmost two digits
      seems safer and avoids differentiating between those two cases.

      Axel
    • Adrian Worsfold
      Hello flo.gehrke and Axel What impresses me is the economy of the code. I m trying to understand it but the whole Regex thing is beyond me and so are some of
      Message 2 of 14 , May 24, 2013
      View Source
      • 0 Attachment
        Hello flo.gehrke and Axel

        What impresses me is the economy of the code. I'm trying to understand it but the whole Regex thing is beyond me and so are some of the advanced and peculiar commands. I spent a long time struggling and hair pulling with the Calc yesterday simply because I forgot to put the $ on at the end. I produced in the end a means to add brackets on the neat minutes and seconds at the end, thus my request to get to neat minutes and seconds.

        No doubt this is very clumsy in your sight, but it does work, and it uses my request to remove blank lines should there be any at the bottom.

        ^!Continue Must place on first line of timings to bracket them.
        ^!ClearVariables
        ^!Set %Pos%=^$GetTextLineCount$
        ^!Set %Lines%=^$GetParaRow$
        ^!Set %Bracket%=^$Calc(^%Pos%-^%Lines%)$
        :LOOP
        ^!Inc %Count%
        ^!Jump LINE_END
        ^!InsertText "]"
        ^!MoveCursor -006
        ^!InsertText "["
        ^!Jump LINE_START
        ^!Jump +001
        ^!IfError END
        ^!If ^%Count% > ^%Bracket% END
        ^!GoTo LOOP
        :END

        That is the third clip in the sequence. The first is:

        ^!Toolbar New Document
        ^!Set %Preacher%=^?[Click on the Service Taker's name=_Adrian Worsfold|Barry Cundill|Bernard McHugh|Chris Pilkington|David Arthur|Elizabeth Faiers|Ernest Baker|Jim Timiney|John Midgley|John Williams|June Pettitt|Keith Brown|Marion Baker|Mavis Lake|Michael Tracey|Rosemary Arthur|Stephanie Cage|Stephen Carlile]
        ^!Info [L]"Print the CD Cover to PDF and copy the tracks.^PAlso note the total time of tracks before the first hymn^P(wipe out first hymn onward - do not save!)."
        ^!ShellWait "C:\Program Files\CDBurnerXP\cdbxpp.exe"
        ^!SetScreenUpdate Off
        ^!InsertHTML ^P^P

        ^!Set %Date%=^$GetDateFromInt(^$Calc(CEIL((^$GetDateToInt$+6)/7)*7-6)$;yyyymmdd)$
        ^!Set %Filename%="Service ^%Date%"
        ^!Toolbar New Document
        ^!Set %Trackslist1%=^$Getclipboard$
        ^!InsertText ^%Trackslist1%
        ^!Replace "\x20+$" >> "" ARSW
        ;Merge sections
        ^!Replace "^(\d+)\R(.+)\R(\d.*:.*)$" >> "$1 $2 $3" ARSW
        ^!Clip "Sorting numbers zeros"
        ^!Jump Doc_Start
        ^!Replace "00^P01" >> "^P01" S
        ^!Select All
        ^!Set %Trackslist2%=^$GetSelection$

        ^!DestroyDoc
        ^!FocusDoc
        ;Removes last lines if blank
        ^!Replace "\R{1,}\Z" >> "" WRS
        ^!Jump Doc_Start
        ^!Set %Minutes%=^?{Minutes Long (two digits)=20}
        ^!Set %Seconds%=^?{Seconds Long (two digits)=00}
        ^!Set %Minsclock%=^$Calc(60-^%Minutes%)$
        ^!InsertText "^P^PService ^%Date%^P^P^%Preacher%^P^P^P<Start 10:^%Minsclock% for 11:00 start [^%Minutes%:^%Seconds%]>^P^P"
        ^!InsertText ^%Trackslist2%
        ^!Replace " 00:" >> " " WAS
        ^!IfError Next else Skip_-1
        ^!Replace ".0^P" >> "^P" WAS
        ^!IfError Next else Skip_-1
        ^!Save As "C:\Shared Documents\Music\^%Filename%.txt"
        ^!SetScreenUpdate On

        "Sorting numbers zeros" is a pinch from another discussion on here. I realised that the 20 was a space and substituted using 30 to get zeros. So I'm not completely thick with these.

        ^!SetHintInfo Working...
        ^!SetScreenUpdate Off
        ^!Set %dig%=2
        ^!Find "^\d{^%dig%}" WRS
        ^!IfError Skip_2
        ^!Inc %dig%
        ^!Goto Skip_-3
        ^!Dec %dig%
        ^!Set %q%=^$Calc(^%dig%-1)$
        ^!Replace "^" >> "^$StrFill(\x30;^%dig%)$" WARS
        ^!Replace "^\x30+?(.{^%q%}\d\b)" >> "$1" WARS
        ^!Select All
        ^$StrSort("^$GetSelection$";0;1;0)$

        And then the second clip is the one you've just done to get rid of decimals. So keeping these separate I will try (when I do my next CD) a clip "Music Order Whole" that consists of:

        ^!Clip "Music Order" [above, using the one just above]
        ^!Clip "Timings whole seconds" [the one you've just done]
        ^!Clip "Brackets square end" [top one]

        So once again thank you very much.



        Adrian Worsfold

        http://www.pluralist.co.uk
        http://pluralistspeaks.blogspot.com
        pluralist@...
        24-05-2013
        ----- Received the following content -----
        From: flo.gehrke
        Receiver: ntb-clips
        Time: 2013-05-24, 14:54:20
        Subject: [Clip] Re: Adding a second when there's a tenth or more


        [Non-text portions of this message have been removed]
      • Axel Berger
        ... Addendum: Just changing ^!Find ([0][1-9]):60$ RS to ^!Find ([0][0-8]):60$ RS will suffice and without the bother of changing everything. It deals with
        Message 3 of 14 , May 24, 2013
        View Source
        • 0 Attachment
          Axel Berger wrote:
          > It seems to me that for 09:60 your soultion will fail.

          Addendum:
          Just changing
          ^!Find "([0][1-9]):60$" RS
          to
          ^!Find "([0][0-8]):60$" RS
          will suffice and without the bother of changing everything. It deals
          with the changeover to ten and with very short clips of less than a
          minute.

          Axel
        • flo.gehrke
          ... Thanks for that hint, Axel. I had prepared the following reply before I could study your next post. So before getting to this let me post my first reply in
          Message 4 of 14 , May 24, 2013
          View Source
          • 0 Attachment
            --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
            >
            > "flo.gehrke" wrote:
            > > ^!Find "([0][1-9]):60$" RS
            > > ^!Find "(\d\d):60$" RS
            >
            > It took me some time to understand why you treat those two cases
            > differently. It seems to me that for 09:60 your soultion will fail.

            Thanks for that hint, Axel. I had prepared the following reply before I could study your next post. So before getting to this let me post my first reply in order to answer your question:

            The problem I saw is with a time like '03:59.9'. See the steps:

            1. 03:59.9 >> 03:60

            2. 03:60 >> 4:00

            NT strips off the leading zero here when calculating...

            ^!Find "([0][1-9]):60$" RS
            ^!IfError Skip_2
            ^!InsertText "^$Calc(^$GetReSubStrings$+1)$:00"

            That's why I tried to resolve this by adding a leading zero to minutes from '01' through '09'

            ^!InsertText "0^$Calc(^$GetReSubStrings$+1)$:00"

            To distinguish between '03:60' and a time like '11:45' (where a no leading 0 is needed) I wrote '([0][1-9])'.

            Unfortunately, I didn't test a time like '09:59.7'. Since there is a leading 0, the clip makes it a '010:00', i.e. a surplus 0 at the beginning.

            As a "quick & dirty" solution, I would try now...

            ^!Jump Doc_Start
            :Seconds
            ^!Find "(\d\d)\.\d$" RS
            ^!IfError Skip_2
            ^!InsertText "^$Calc(^$GetReSubstrings$+1)$"
            ^!Goto Seconds
            ^!Jump Doc_Start
            :Minutes_1
            ^!Find "([0][1-8]):60$" RS
            ^!IfError Skip_2
            ^!InsertText "0^$Calc(^$GetReSubStrings$+1)$:00"
            ^!Goto Minutes_1
            ^!Jump Doc_Start
            ^!Find "([0][1-9]):60$" RS
            ^!IfError Skip_2
            ^!InsertText "^$Calc(^$GetReSubStrings$+1)$:00"
            ^!Goto Skip_-3
            ^!Jump Doc_Start
            :Minutes_2
            ^!Find "(\d\d):60$" RS
            ^!IfError End
            ^!InsertText "^$Calc(^$GetReSubStrings$+1)$:00"

            Now the list...

            01:58.4
            02:46.5
            03:59.9
            11:44.4
            15:59.5
            09:58
            09:59.7

            is changed to...

            01:59
            02:47
            04:00
            11:45
            16:00
            09:58
            10:00

            Is this OK now? I'll be back in a few hours ;-)

            Regards,
            Flo
          • Adrian Worsfold
            Hello flo.gehrke IN the new version of your clip, 07:03.3 becomes 07:4 with no zero. Adrian Worsfold http://www.pluralist.co.uk
            Message 5 of 14 , May 24, 2013
            View Source
            • 0 Attachment
              Hello flo.gehrke


              IN the new version of your clip, 07:03.3 becomes 07:4 with no zero.




              Adrian Worsfold

              http://www.pluralist.co.uk
              http://pluralistspeaks.blogspot.com
              pluralist@...
              24-05-2013
              ----- Received the following content -----
              From: flo.gehrke
              Receiver: ntb-clips
              Time: 2013-05-24, 18:33:23
              Subject: [Clip] Re: Adding a second when there's a tenth or more


              [Non-text portions of this message have been removed]
            • flo.gehrke
              ... I think there s another issue. Please test it against... 15:59.5 09:58 09:59.7 When changing only that single command line as proposed the result is...
              Message 6 of 14 , May 24, 2013
              View Source
              • 0 Attachment
                --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
                >
                > > It seems to me that for 09:60 your soultion will fail.
                > Addendum:
                > Just changing
                > ^!Find "([0][1-9]):60$" RS
                > to
                > ^!Find "([0][0-8]):60$" RS
                > will suffice and without the bother of changing everything. It deals
                > with the changeover to ten and with very short clips of less than a
                > minute.

                I think there's another issue. Please test it against...

                15:59.5
                09:58
                09:59.7

                When changing only that single command line as proposed the result is...

                16:00
                09:58
                09:60 <--- false

                So let's combine both '[0][1-8]' and '[0][1-9]'.

                We also have to take care of zeros in the seconds. It might be rare but a '10:00.1 is turned into '10.1'. Well, let's get rid of that with the last line in the next version ("hopefully mother won't see it"):

                ^!SetHintInfo Working...
                ^!SetScreenUpdate Off
                ^!Jump Doc_Start
                :Seconds
                ^!Find "(\d\d)\.\d$" RS
                ^!IfError Skip_2
                ^!InsertText "^$Calc(^$GetReSubstrings$+1)$"
                ^!Goto Seconds
                ^!Jump Doc_Start
                :Minutes_1
                ^!Find "([0][1-8]):60$" RS
                ^!IfError Skip_2
                ^!InsertText "0^$Calc(^$GetReSubStrings$+1)$:00"
                ^!Goto Minutes_1
                ^!Jump Doc_Start
                :Minutes_2
                ^!Find "([0][1-9]):60$" RS
                ^!IfError Skip_2
                ^!InsertText "^$Calc(^$GetReSubStrings$+1)$:00"
                ^!Goto Minutes_2
                ^!Jump Doc_Start
                ^!Find "(\d\d):60$" RS
                ^!IfError Out
                ^!InsertText "^$Calc(^$GetReSubStrings$+1)$:00"
                :Out
                ^!Replace ":\K(?=\d$)" >> "0" WARS

                Please test it against another list:

                01 xxx 01:58.4
                02 xxx 02:46.5
                03 xxx 03:59.9
                04 xxx 11:44.4
                05 xxx 15:59.5
                06 xxx 09:58
                07 xxx 09:59.7
                08 xxx 10:00.1
                09 xxx 10:09.1
                10 xxx 10:01.3
                11 xxx 12:10.4
                12 xxx 07:03.3

                For me, the result is now:

                01 xxx 01:59
                02 xxx 02:47
                03 xxx 04:00
                04 xxx 11:45
                05 xxx 16:00
                06 xxx 09:58
                07 xxx 10:00
                08 xxx 10:01
                09 xxx 10:10
                10 xxx 10:02
                11 xxx 12:11
                12 xxx 07:04

                Regards,
                Flo
              • flo.gehrke
                ... Yes, you are right. I included that in my last message. Flo
                Message 7 of 14 , May 24, 2013
                View Source
                • 0 Attachment
                  --- In ntb-clips@yahoogroups.com, "Adrian Worsfold"<pluralist@...> wrote:
                  >
                  > Hello flo.gehrke
                  > IN the new version of your clip, 07:03.3 becomes 07:4 with no zero.

                  Yes, you are right. I included that in my last message.

                  Flo
                • Axel Berger
                  ... I haven t run any tests so far, only read and tried to understand your code. I don t see why 09:60 isn t caught by your subsequent ^!Find ( d d):60$ RS
                  Message 8 of 14 , May 24, 2013
                  View Source
                  • 0 Attachment
                    "flo.gehrke" wrote:
                    > Please test it against...
                    > When changing only that single command line as proposed the result is...
                    > 09:60 <--- false

                    I haven't run any tests so far, only read and tried to understand your
                    code. I don't see why 09:60 isn't caught by your subsequent

                    ^!Find "(\d\d):60$" RS

                    It should be.

                    Axel
                  • Axel Berger
                    ... There was. I have now run your clip of 15:54 h with my modification and lots of ^!Continue when stumped. You forgot the last loop and the d d Find was run
                    Message 9 of 14 , May 24, 2013
                    View Source
                    • 0 Attachment
                      "flo.gehrke" wrote:
                      > I think there's another issue. Please test it against...

                      There was. I have now run your clip of 15:54 h with my modification and
                      lots of ^!Continue when stumped. You forgot the last loop and the \d\d
                      Find was run only once. After adding
                      ^!Goto Minutes_2
                      as a last line it worked fine. Looking at your later posts that error
                      seems to persist.

                      Axel
                    • flo.gehrke
                      ... Yes, I came across that too. Another loop is missing: ^!SetHintInfo Working... ^!SetScreenUpdate Off ^!Jump Doc_Start ... ^!Find ( d d) . d$ RS ^!IfError
                      Message 10 of 14 , May 24, 2013
                      View Source
                      • 0 Attachment
                        --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
                        >
                        > You forgot the last loop and the \d\d Find was run only once.
                        > After adding ^!Goto Minutes_2 as a last line it worked fine.

                        Yes, I came across that too. Another loop is missing:

                        ^!SetHintInfo Working...
                        ^!SetScreenUpdate Off
                        ^!Jump Doc_Start
                        :Seconds
                        ^!Find "(\d\d)\.\d$" RS
                        ^!IfError Skip_2
                        ^!InsertText "^$Calc(^$GetReSubstrings$+1)$"
                        ^!Goto Seconds
                        ^!Jump Doc_Start
                        :Minutes_1
                        ^!Find "([0][1-8]):60$" RS
                        ^!IfError Skip_2
                        ^!InsertText "0^$Calc(^$GetReSubStrings$+1)$:00"
                        ^!Goto Minutes_1
                        ^!Jump Doc_Start
                        :Minutes_2
                        ^!Find "([0][1-9]):60$" RS
                        ^!IfError Skip_2
                        ^!InsertText "^$Calc(^$GetReSubStrings$+1)$:00"
                        ^!Goto Minutes_2
                        ^!Jump Doc_Start
                        :Minutes_3
                        ^!Jump Doc_Start
                        ^!Find "(\d\d):60$" RS
                        ^!IfError Out
                        ^!InsertText "^$Calc(^$GetReSubStrings$+1)$:00"
                        ^!Goto Minutes_3
                        :Out
                        ^!Replace ":\K(?=\d$)" >> "0" WARS

                        New test list - before...

                        01 xxx 01:58.4
                        02 xxx 12:59.7
                        03 xxx 03:59.9
                        04 xxx 11:44.4
                        05 xxx 15:59.5
                        06 xxx 09:58
                        07 xxx 09:59.7
                        08 xxx 10:00.1
                        09 xxx 10:09.1
                        10 xxx 10:01.3
                        11 xxx 12:10.4
                        12 xxx 07:03.3

                        And after...

                        01 xxx 01:59
                        02 xxx 13:00
                        03 xxx 04:00
                        04 xxx 11:45
                        05 xxx 16:00
                        06 xxx 09:58
                        07 xxx 10:00
                        08 xxx 10:01
                        09 xxx 10:10
                        10 xxx 10:02
                        11 xxx 12:11
                        12 xxx 07:04

                        Have we got it now? :-(

                        Flo
                      • flo.gehrke
                        ... Adrian, I just had a look at this detail in your message. If it s about something like this (given only 6 time lines): Before: xxx xxx xxx 01 xxx 01:59 02
                        Message 11 of 14 , May 24, 2013
                        View Source
                        • 0 Attachment
                          --- In ntb-clips@yahoogroups.com, "Adrian Worsfold"<pluralist@...> wrote:

                          > ^!Set %Pos%=^$GetTextLineCount$
                          > ^!Set %Lines%=^$GetParaRow$
                          > ^!Set %Bracket%=^$Calc(^%Pos%-^%Lines%)$
                          > :LOOP
                          > ^!Inc %Count%
                          > ^!Jump LINE_END
                          > ^!InsertText "]"
                          > ^!MoveCursor -006
                          > ^!InsertText "["
                          > ^!Jump LINE_START
                          > ^!Jump +001
                          > ^!IfError END
                          > ^!If ^%Count% > ^%Bracket% END
                          > ^!GoTo LOOP
                          > :END
                          >
                          > That is the third clip in the sequence.

                          Adrian,

                          I just had a look at this detail in your message. If it's about something like this (given only 6 time lines):

                          Before:

                          xxx xxx xxx
                          01 xxx 01:59
                          02 xxx 13:00
                          03 xxx 04:00
                          04 xxx 11:45
                          05 xxx 16:00
                          06 xxx 09:58
                          zzz zzz

                          Isn't that done with one line:

                          ^!Replace "(\d\d:\d\d)$" >> "[$0]" WARS

                          After:

                          xxx xxx xxx
                          01 xxx [01:59]
                          02 xxx [13:00]
                          03 xxx [04:00]
                          04 xxx [11:45]
                          05 xxx [16:00]
                          06 xxx [09:58]
                          zzz zzz

                          Possibly no loops, jumps, and cursor movements needed here.

                          Flo
                        • Adrian Worsfold
                          Hello Flo and Axel This ^!Replace ( d d: d d)$ [$0] WARS replaced many of my lines. I don t understand Regex and so I did it the long way with
                          Message 12 of 14 , May 24, 2013
                          View Source
                          • 0 Attachment
                            Hello Flo and Axel

                            This ^!Replace "(\d\d:\d\d)$" >> "[$0]" WARS replaced many of my lines. I don't understand Regex and so I did it the long way with head-banging on the route. But thanks for the error solved and this too.

                            Late it is now, but here is the usual time I do make up a CD. I'll do it for real and let you know how it goes (I haven't even chosen some of the music yet, but it will be very different from the given list).

                            * There is one final potential clip that hardly saves on human viewing, but one may as well push it to the logical end.

                            After the number, the presence of HL nnn, SF nnn, LS nn, CC nn, HW nnn, HF nnn, or NB nn indicates a hymn book (or latter no book still with numbers up to 99). Before each hymn book, and after it but not before another hymn book, there is a blank line inserted. This is to tell me to use a second CD made at a higher level of volume which people sing against. Now I am sure this is within my abilities, eventually, the complication being not wanting a blank line in between two hymns indicated by either leading code after the number.

                            Thus a final appearance result would be:

                            01 Temptations Papa was a Rollin Stone [11:47]
                            02 KamakawiwoOleIsrael Somewhere Over the Rainbow [04:55]
                            03 SheeranEd A Team [04:22]
                            04 PresleyElvis In The Ghetto [02:48]
                            05 Clannad I See Red [04:25]

                            06 HL 018 Kremser choir [01:27]
                            07 HL 070 Hanover [02:51]

                            08 KingCarole Youve Got a Friend [05:10]

                            09 HL 051 Stuttgart [01:59]

                            10 Debussy Claire de Lune Suite extract [02:00]

                            11 HL 210 Jerusalem choir [02:47]

                            12 CollinsPhil Homeless [04:15]
                            13 PineCourtney Closer to Home [03:56]
                            14 PineCourtney GreeneSusaye Children of the Ghetto [07:04]
                            15 Housemartins I'll be Your Shelter [04:52]
                            16 Simply Red Moneys Too Tight to Mention [04:15]

                            All of these are HLs but SFs are as common and the rest very occasional but available.

                            Automation of the WHOLE process isn't possible because nothing could guide the CD burner print to .PDF after the burn process. That's the human bit during the ^!shellwait after which the first clip works its magic. But this last part does follow regular internal rules.



                            Adrian Worsfold

                            http://www.pluralist.co.uk
                            http://pluralistspeaks.blogspot.com
                            pluralist@...
                            25-05-2013
                            ----- Received the following content -----
                            From: flo.gehrke
                            Receiver: ntb-clips
                            Time: 2013-05-24, 23:03:23
                            Subject: [Clip] Re: Adding a second when there's a tenth or more


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