Formatting ChordPro music charts

Jan Schenkel janschenkel at yahoo.com
Thu Nov 10 07:06:32 EST 2011


Hi Mark,

Glad to be of assistance. I just took another look at it, and realized that there's still a case where my algorithm didn't work: when the lyrics under the chord are shorter than the chord. The following adapted version should fix that for you:

##
on mouseUp
   put ChordProPrintText(field "ChordProText") into field "PrintText"
end mouseUp

private function ChordProPrintText pChordProText
   local tPrintText, tLine, tIndex, tInBracketFlag, tChords, tLyrics
   repeat for each line tLine in pChordProText
      put empty into tChords
      put empty into tLyrics
      put false into tInBracketFlag
      repeat with tIndex = 1 to the number of characters in tLine
         if char tIndex of tLine is "[" then
            put true into tInBracketFlag
            if tChords is not empty and char -1 of tChords is not space then
               put space after tChords
            end if
            repeat (the number of characters in tChords) - (the number of characters in tLyrics) times
               put space after tLyrics
            end repeat
         else if char tIndex of tLine is "]" then
            put false into tInBracketFlag
         else if tInBracketFlag is true then
            put char tIndex of tLine after tChords
         else
            put char tIndex of tLine after tLyrics
            if the number of characters in tChords < the number of characters in tLyrics then
               put space after tChords
            end if
         end if
      end repeat
      put tChords & return & tLyrics & return after tPrintText
   end repeat
   return char 1 to -2 of tPrintText -- no trailing return
end ChordProPrintText

##


Cheers,

Jan Schenkel.

=====
Quartam Reports & PDF Library for LiveCode
www.quartam.com


=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


________________________________
From: Mark Stuart <mfstuart at cox.net>
To: use-revolution at lists.runrev.com
Sent: Tuesday, November 8, 2011 5:49 PM
Subject: Re: Formatting ChordPro music charts

Jan, you are brilliant. Thank you very much for the script, it works exactly
as expected.
Even with chords like Dsus2, F#, Bb, Cm7, etc.

So thanx again. Now to finish this project... another story.

Regards,
Mark Stuart


More information about the use-livecode mailing list