Formatting ChordPro music charts
Jan Schenkel
janschenkel at yahoo.com
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
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
##
HTH,
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-livecode at lists.runrev.com
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
[A]Hey.
When printed it looks like this:
A D
This is my song
A D
It's not very long
A
Hey
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?
Regards,
Mark Stuart
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list