Formatting ChordPro music charts

Jan Schenkel janschenkel at
Tue Nov 8 00:50:38 EST 2011

Ooh, another breakfast cereal challenge - what better way to start the day? :-)
Here's my take on it; only lightly tested but looked alright in my variations:

on mouseUp
   putChordProPrintText(field"ChordProText") intofield"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
         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
            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


Jan Schenkel.
Quartam Reports & PDF Library for LiveCode

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

From: Mark Stuart <mfstuart at>
To: use-livecode at
Sent: Tuesday, November 8, 2011 6:06 AM
Subject: Formatting ChordPro music charts

Hi all,
Anyone familiar with the ChordPro music chart format?
I want to build a desktop app that would allow the user to edit the song
chart, and then print it, all using the ChordPro format.

Editing the chart looks like this:

[A]This is my [D]song
[A]It's not very [D]long

When printed it looks like this:

A          D
This is my song
A             D
It's not very long

The key is printed directly above where the key was entered into the chart.
The printing script would have to read each line, looking for the opening [
square bracket, look for the next closing ] square bracket, and format that
content into a line including spacing based on the line it found the square
brackets on.

I'm not sure how to do that. Anyone with some ideas on this?

Mark Stuart

use-livecode mailing list
use-livecode at
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the Use-livecode mailing list