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

Different way to the same thing

Expand Messages
  • Adrian Worsfold
    Hello ntb-clips. Me again. This is a tale of what should work but doesn t. Instead of going to the .PDF output of the burn list of a CD, there is the saved
    Message 1 of 5 , May 28 11:49 AM
    • 0 Attachment
      Hello ntb-clips. Me again.

      This is a tale of what should work but doesn't. Instead of going to the .PDF output of the burn list of a CD, there is the saved file. An example looks like this.

      <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      <!DOCTYPE layout PUBLIC "http://www.cdburnerxp.se/help/audio.dtd" "">
      <?xml-stylesheet type='text/xsl' href='http://www.cdburnerxp.se/help/compilation.xsl'?>
      <!--audio compilation created by CDBurnerXP 4.3.7.2423 (http://cdburnerxp.se)-->
      <layout type="Audio" version="4.3.7.2423" date="2012-11-10" time="05:31">
      <compilation name="audio-template" title="" artist="">
      <track path="C:\Shared Documents\Music\Service\ReynoldsMalvina God bless the Grass.wav" title="" artist="" number="1" />
      <track path="C:\Shared Documents\Music\Service\Purcell ECO Dido Aeneas When I am Laid in Earth.wav" title="" artist="" number="2" />
      <track path="C:\Shared Documents\Music\Service\Fairport Convention Who Knows Where the Time Goes.wav" title="" artist="" number="3" />
      <track path="C:\Shared Documents\Music\Service\Fairport Convention Celtic Moon.wav" title="" artist="" number="4" />
      <track path="C:\Shared Documents\Music\Service\Fairport Convention Around Wild Cape Horn.wav" title="" artist="" number="5" />
      <track path="C:\Shared Documents\Music\Service\Perlman Schindlers List Remebrances.wav" title="" artist="" number="6" />
      <track path="C:\Shared Documents\Music\Service\BogleEric Green Fields of France.wav" title="" artist="" number="7" />
      <track path="C:\Shared Documents\Music\Service\JenkinsKarl Adiemus Benedictus.wav" title="" artist="" number="8" />
      <track path="C:\Shared Documents\Music\Service\JenkinsKarl Armed Man Agnus Dei.wav" title="" artist="" number="9" />
      <track path="C:\Shared Documents\Music\Service\JenkinsKarl Armed Man For the Fallen In Memoriam.wav" title="" artist="" number="10" />
      <track path="C:\Shared Documents\Music\Service\Lord of the Rings Fellowship Broken May It Be.wav" title="" artist="" number="11" />
      <track path="C:\Shared Documents\Music\Service\ArnoldPP Im a Dreamer.wav" title="" artist="" number="12" />
      <track path="C:\Shared Documents\Music\Service\PriorMaddy Fotheringay.wav" title="" artist="" number="13" />
      <track path="C:\Shared Documents\Music\Service\ConwayRuss Roulette.wav" title="" artist="" number="14" />
      <track path="C:\Shared Documents\Music\Service\ConwayRuss Side Saddle.wav" title="" artist="" number="15" />
      <track path="C:\Shared Documents\Music\Service\DennySandy Who Knows Where the Time Goes.wav" title="" artist="" number="16" />
      </compilation>
      </layout>

      So I made a clip that should work, but of course it doesn't. The intention is to produce a numbered list equivalent to the one I was getting from the .PDF, which is a list of leading zeros tracks 1 to 9 and then double followed by a space before the simple track name. This clip below works so far, but fails on a syntax error that actually works in another clip.

      Here is the clip in full to where I have wanted it at present:

      ^!Clearvariables
      ^!SetWordWrap OFF
      ; Remove spaces at start or end of lines
      ^!Replace "^\x20+|\x20+$" >> "" WARS
      ^!Replace "\x20{1,}$" >> "" WARS
      ^!Jump Doc_Start
      ^!Find "artist="">"
      ^!Set %Lines%=^$Calc(^$GetParaRow$-1)$
      ^!Jump Doc_Start

      :LOOP
      ^!Inc %Count%
      ^!DeleteLine
      ^!If ^%Count% > ^%Lines% FRED
      ^!GoTo LOOP

      :FRED

      ^!Replace "<track path="C:\Shared Documents\Music\Service\" >> "" WAS
      ^!Replace ".wav" title="" artist="" number="" >> "" WAS
      ^!Replace "</compilation>^P</layout>" >> "" WAS
      ^!Set %Linesleft%=^$GetParaRow$

      :LOOPY
      ^!Inc %Number%
      ^!If ^%Number% > ^%Linesleft% BOB
      ^!Jump Doc_Start
      ^!Replace "^%Number%" />" >> "" S
      ^!GoTo LOOPY

      :BOB

      ^!Set %StartInc%=1
      ^!Set %StartTop%=1
      ^!Set %LeadZero%=Yes
      ^!Set %AddChr%=" "
      ^!Set %StopInc%=0
      ^!Set %SkipLine%=0

      ^!IfTrue ^$IsEmpty("^$GetText$")$ Next else Skip
      ^!Set %NewDoc%=1
      ^!Set %StrSize%=^$StrSize(^%StopInc%)$
      ^!StatusShow Ordering Line Numbers...
      ^!SetScreenUpdate Off
      ^!IfFalse ^$IsWordWrap$ Skip_2
      ^!ToolBar Toggle Word Wrap
      ^!Set %WrapOff%=1
      ^!IfTrue ^%StartTop% Next else Skip
      ^!Jump 1
      :StartLoop
      ^!IfTrue ^%NewDoc% NewDoc
      ^!IfTrue ^%SkipLine% Next else Skip
      ^!IfTrue ^$IsEmpty("^$GetLine$")$ SkipLine
      ^!IfTrue ^%LeadZero% Next else Skip_2
      ^!InsertText ^$StrFill("0";^$Calc(^%StrSize%-^$StrSize("^%StartInc%")$)$)$^%StartInc%^%AddChr%
      ^!Goto Skip
      ^!InsertText ^%StartInc%^%AddChr%
      ^!Inc %StartInc%
      ^!Goto SkipLine
      :NewDoc
      ^!IfTrue ^%LeadZero% Next else Skip_2
      ^!InsertText ^$StrFill("0";^$Calc(^%StrSize%-^$StrSize("^%StartInc%")$)$)$^%StartInc%^%AddChr%^p
      ^!Goto Skip
      ^!InsertText ^%StartInc%^%AddChr%^p
      ^!Inc %StartInc%
      :SkipLine
      ^!Jump +1
      ^!IfTrue ^%NewDoc% Skip
      ^!If ^$GetLineCount$ = ^$GetRow$ Top
      ^!If ^%StartInc% = ^$Calc(^%StopInc%+1;0)$ Top else StartLoop
      :Top
      ^!IfFalse ^%WrapOff% Skip
      ^!ToolBar Toggle Word Wrap
      ^!Jump 1
      ^!SetWordwrap ON

      Now the line that fails as a syntax error is this one:

      ^!InsertText ^$StrFill("0";^$Calc(^%StrSize%-^$StrSize("^%StartInc%")$)$)$^%StartInc%^%AddChr%^p

      And yet it works where the

      ^!ClearVariables

      ^!Set %StartInc%=1
      ^!Set %StartTop%=1
      ^!Set %LeadZero%=Yes
      ^!Set %AddChr%=" "
      ^!Set %StopInc%=0
      ^!Set %SkipLine%=0
      used to be a wizard. So this works! I cannot see why a line that works in one setting doesn't in another. I've really tried to take nothing away
      The result of my constructed clip up to the syntax error is this:
      1 ReynoldsMalvina God bless the Grass
      2 Purcell ECO Dido Aeneas When I am Laid in Earth
      3 Fairport Convention Who Knows Where the Time Goes
      4 Fairport Convention Celtic Moon
      5 Fairport Convention Around Wild Cape Horn
      6 Perlman Schindlers List Remebrances
      7 BogleEric Green Fields of France
      8 JenkinsKarl Adiemus Benedictus
      9 JenkinsKarl Armed Man Agnus Dei
      JenkinsKarl Armed Man For the Fallen In Memoriam
      Lord of the Rings Fellowship Broken May It Be
      ArnoldPP Im a Dreamer
      PriorMaddy Fotheringay
      ConwayRuss Roulette
      ConwayRuss Side Saddle
      DennySandy Who Knows Where the Time Goes
      Yet with the wizard and selecting, a separate line nubering clip produces the full numbering. Surely that can be incorporated! This works:
      ^!ClearVariables
      ^!SetWizardLabel Line numbering options
      ^!Set %Row%=1; %StartInc%=1; %StartTop%=^?{Star&t numbering at=_Top of document^=1|Cursor position^=}; %LeadZero%=^?{Add leading &zeros to small numbers=_Yes|No}; %AddChr%=^?{Add &character after number: period and space shown=None^=|_. }; %StopInc%=^?{&Stop numbering at what line number (enter number if new doc)=_End of Document^=^$GetLineCount$|}; %SkipLine%=^?{Skip numbering of &blank lines=_Yes|No^=}
      The rest follows as above.

      The problem is there is no menu alternative because it asks where the numbering starts and there is no option to put in a space rather than its given full stop.

      All assistance is again very welcome.







      Adrian Worsfold

      http://www.pluralist.co.uk
      http://pluralistspeaks.blogspot.com
      pluralist@...
      28-05-2013


      [Non-text portions of this message have been removed]
    • flo.gehrke
      ... Adrian, I get an syntax error in line 56. I think the reason is this: With every loop, you increase %StartInc%. This works up to 9 . When increasing
      Message 2 of 5 , May 29 8:50 AM
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "Adrian Worsfold"<pluralist@...> wrote:
        >
        > (...) Now the line that fails as a syntax error is this one:
        >
        > ^!InsertText ^$StrFill("0";^$Calc(^%StrSize%-^$StrSize("^%StartInc%")$)$)$^%StartInc%^%AddChr%^p (...)
        >
        > I cannot see why a line that works in one setting doesn't
        > in another.

        Adrian,

        I get an syntax error in line 56. I think the reason is this:

        With every loop, you increase %StartInc%. This works up to '9'. When increasing %StartInc% from '9' to '10', the amount of characters to get inserted is calculated as '1-10', i.e. it's negative. Note that NT can't execute '^$StrFill$' with a negative amount:

        ^!Info ^$StrFill("x";-10)$

        You can reproduce that error with...

        ^!SetDebug On
        ^!Set %StrSize%=1; %StartInc%=8; %AddChr%=0
        :Start
        ^!InsertText ^$StrFill("0";^$Calc(^%StrSize%-^$StrSize("^%StartInc%")$)$)$^%StartInc%^%AddChr%^P
        ^!Inc %StartInc%
        ^!Goto Start


        BTW, what about a shorter solution that has been tested against your data and that possibly could match your intention as well?

        If I'm not mistaken, the clip is meant to change those sample data to...


        1 ReynoldsMalvina God bless the Grass
        2 Purcell ECO Dido Aeneas When I am Laid in Earth
        3 Fairport Convention Who Knows Where the Time Goes
        4 Fairport Convention Celtic Moon
        5 Fairport Convention Around Wild Cape Horn
        6 Perlman Schindlers List Remebrances
        7 BogleEric Green Fields of France
        8 JenkinsKarl Adiemus Benedictus
        9 JenkinsKarl Armed Man Agnus Dei
        10 JenkinsKarl Armed Man For the Fallen In Memoriam
        11 Lord of the Rings Fellowship Broken May It Be
        12 ArnoldPP Im a Dreamer
        13 PriorMaddy Fotheringay
        14 ConwayRuss Roulette
        15 ConwayRuss Side Saddle
        16 DennySandy Who Knows Where the Time Goes


        If so, please try...

        ^!Replace "^\x20+" >> "" WARS
        ^!Replace "(?s)^.+?title=(\x22\x22)\x20artist=\1>\R" >> "" WRS
        ^!Replace "^<track.+?Service\\" >> "" WARS
        ^!Replace "\.wav.+$" >> "" WARS
        ^!Replace "(?s)\R</compilation.+" >> "" WRS
        ; Number lines
        ^!SetWordWrap Off
        ^!Set %Ln%=^$GetTextLineCount$
        :Loop
        ^!Jump ^%Ln%
        ^!InsertText ^%Ln%^%Space%
        ^!Dec %Ln%
        ^!If ^%Ln% > 0 ^!Goto Loop


        Maybe this gets pretty close to your intention. Ask again if I missed anything.

        Regards,
        Flo
      • Adrian Worsfold
        Hello Flo Yes I thought you might produce a much faster and more efficient way to produce a simple list. This list is different in so far as it comes from the
        Message 3 of 5 , May 29 10:27 AM
        • 0 Attachment
          Hello Flo

          Yes I thought you might produce a much faster and more efficient way to produce a simple list.

          This list is different in so far as it comes from the burn list .axp file and contains no information on timings. The information on timings comes from the presence of the files and this is what enables the CD cover to be printed to .PDF and it is from that .PDF that the list with timings in brackets is derived. That will always be the main list I use, and I made a variation for any CD burning rather than one for a Sunday service.

          With an .axp file available it is always possible to make a list even if the music files are not available.

          So I have incorporated your effort into the body of a second .axp to .txt clip, AXP to TXT (nt shorter), and it now looks like:

          ^!Close ALL
          ^!Save AS C:\Shared Documents\Music\temp.tmp
          ^!SetWizardLabel Press OK for AXPs here or navigate
          ^!Set %Folder%=^?{(T=D)&Browse: Confirm OK or press the button=^$GetValue(DirStuff:Browse)$}
          ^!StatusShow Finding files...
          ^!SetScreenUpdate Off
          ^!Set %Type%=*.axp
          ^!Set %Sort%=Name
          ^!FocusDoc

          ^!Close DISCARD
          ^!DestroyDoc C:\Shared Documents\Music\temp.tmp

          ^!Set %FullPath%=^$GetFileFirst(^%Folder%;"^%Type%";^%Sort%)$
          ; Checks to see if files are found by search criteria
          ^!IfTrue ^$IsEmpty("^%FullPath%")$ END

          :LOOP1
          ^!IfTrue ^$IsEmpty(^%FullPath%)$ DOARRAY
          ^!Append %Files%=^%FullPath%|
          ^!Set %FullPath%=^$GetFileNext$
          ^!Goto LOOP1

          :DOARRAY
          ^!CloseFileFind
          ^!SetArray %EditList%=^?{(T=L;H=16)Choose=^%Files%}
          ^!Set %Count%=^%EditList0%
          ^!Set %Index%=0

          :LOOP2
          ;When it chooses a file the index position forces it out of the loop
          ^!Set %FilePathFull%=^%EditList^%Index%%
          ^!Inc %Index%
          ^!If ^%Index% > ^%Count% PROCEED
          ^!Toolbar New Document
          ^!FocusDoc
          ^!InsertFile ^%EditList^%Index%%
          ^!GoTo LOOP2

          :PROCEED
          ^!Clearvariables
          ^!Replace "^\x20+" >> "" WARS
          ^!Replace "(?s)^.+?title=(\x22\x22)\x20artist=\1>\R" >> "" WRS
          ^!Replace "^<track.+?Service\\" >> "" WARS
          ^!Replace "\.wav.+$" >> "" WARS
          ^!Replace "(?s)\R</compilation.+" >> "" WRS
          ; Number lines
          ^!SetWordWrap OFF
          ^!Set %Ln%=^$GetTextLineCount$

          :Loop
          ^!Jump ^%Ln%
          ^!InsertText ^%Ln%^%Space%
          ^!Dec %Ln%
          ^!If ^%Ln% > 0 ^!Goto Loop

          ^!Clip "Sorting numbers zeros"

          ;Hymn books gaps
          ^!Replace "^.*\b(HL|SF|LS|CC|HW|HF|NB)\b.*$" >> "\r\n$0\r\n" WARS
          ^!Replace "\R{3}" >> "\r\n" WARS
          ^!Replace "^\A\R|\R{1,}\Z" >> "" WARS
          ^!SetWordwrap ON



          The clip sorting numbers zeros is used because the wizard did leading zeros and this alone doesn't. I also have a front end to all the above:

          ^!ClearVariables

          ^!Clip "AXP to TXT (nt shorter)"

          ^!Jump DOC_START

          ^!Set %Preacher%=^?{(T=L;H=18)Click on the Service Taker's or CD Owner'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}

          ^!Set %Date%=^$GetDateFromInt(^$Calc(CEIL((^$GetDateToInt$+6)/7)*7-6)$;yyyymmdd)$
          ^!SetWizardLabel Date and CDs this date Options
          ^!Set %CDDate%=^?{(T=L;H=8)Date of CD=_Next Sunday^=^%Date%|Today^=^$GetDate(yyyymmdd)$}; %AddNum%=^?{Number?=_Only one^=only|First this date^=01|Second this date^=02|Third this date^=03|Fourth this date^=04|Fifth this date^=05}

          ^!Set %Filename%="Simple List ^%CDDate% ^%AddNum%"

          ^!InsertText ^%Preacher%'s CD on ^%CDDate%^P^P

          ^!Save As "C:\Shared Documents\Music\^%Filename%.txt"



          Adrian Worsfold

          http://www.pluralist.co.uk
          http://pluralistspeaks.blogspot.com
          pluralist@...
          29-05-2013
          ----- Received the following content -----
          From: flo.gehrke
          Receiver: ntb-clips
          Time: 2013-05-29, 16:50:01
          Subject: [Clip] Re: Different way to the same thing


          [Non-text portions of this message have been removed]
        • flo.gehrke
          ... I didn t test that again because it seems to work fine. Another idea: Why are those names written as ReynoldsMalvina , for example? Another command
          Message 4 of 5 , May 29 11:15 AM
          • 0 Attachment
            --- In ntb-clips@yahoogroups.com, "Adrian Worsfold"<pluralist@...> wrote:
            >
            > So I have incorporated your effort into the body of a second
            > .axp to .txt clip, AXP to TXT (nt shorter),...

            I didn't test that again because it seems to work fine.

            Another idea: Why are those names written as 'ReynoldsMalvina', for example? Another command line...

            ^!Replace "\b([A-Z][a-z]+)((?1))\b" >> "$2\x20$1:" WARS

            would change that to "Malvina Reynolds:" ;-)

            Regards,
            Flo

            P.S. Sorry, there was a little mistake in my explanation. Correct is: "When increasing %StartInc% from '9' to '10', the amount of characters to get inserted is calculated as '1-2', i.e. it's negative."
          • Adrian Worsfold
            Hello Flo ^!Replace b([A-Z][a-z]+)((?1)) b $2 x20$1: WARS This is a very useful clip, thank you. The SurnameFirstname comes about because it is how I
            Message 5 of 5 , May 29 6:54 PM
            • 0 Attachment
              Hello Flo

              ^!Replace "\b([A-Z][a-z]+)((?1))\b" >> "$2\x20$1:" WARS


              This is a very useful clip, thank you. The SurnameFirstname comes about because it is how I store my music files, but it is a minefield of difficulty. Is Elton John filed under E or J in a library? E - his name is like that of a group. What about Paul McCartney? Not under P is it?

              That will stay as a single clip for use on a sort of as required sense.




              Adrian Worsfold

              http://www.pluralist.co.uk
              http://pluralistspeaks.blogspot.com
              pluralist@...
              30-05-2013
              ----- Received the following content -----
              From: flo.gehrke
              Receiver: ntb-clips
              Time: 2013-05-29, 19:15:20
              Subject: [Clip] Re: Different way to the same thing


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