[JW Lua] flip accidentals in selected regions

Joseph Weidinger jsphweid at gmail.com
Wed May 6 15:34:17 CEST 2015


This almost works... It seems to correctly change the note but it doesn't
stick or save. I'm not sure why it doesn't stick as I do iterate over it
with "eachentrysaved" and even have an entry.CheckAccidentals = true, if
that does anything in this case...  What am I missing?

Thanks!

tblOne = {'A#', 'B#', 'C#', 'D#', 'E#', 'F#', 'G#', 'Cb', 'Fb', 'Bb', 'Db',
'Eb', 'Gb', 'Ab'}
tblTwo = {'Bb', 'C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'B', 'E', 'A#', 'C#',
'D#', 'F#', 'G#'}

local pitchString = finale.FCString()
local originalPitchString = finale.FCString()

for entry in eachentrysaved(finenv.Region()) do
    if entry:IsNote() then
        for note in each(entry) do
            note:GetString(pitchString, nil, false, true)
            note:GetString(originalPitchString, nil, false, true)
            for k, v in ipairs(tblOne) do
                if pitchString:ContainsLuaString(v, nil) then
                    pitchString:Replace(tblOne[k], tblTwo[k])
                    print("The pitch", originalPitchString.LuaString, "was
changed to", pitchString.LuaString)
                    break
                end
            end
        end
    end
    entry.CheckAccidentals = true
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20150506/0e965a8e/attachment-0002.html>


More information about the JWLua mailing list