[JW Lua] No Finale "Undo" possible after font change when script has error

Jan Angermüller jan at angermueller.com
Thu Feb 19 17:14:09 CET 2015


Jari,

if a Lua script has an error that leads to a stop AND a default font had 
been changed before the error occured, the font change will not be 
undo-able in the Finale document.

I.e. usually when a script halts, no changes to the Finale database are 
being stored.
But in this case, the default font has already changed and can't be 
undone, as "Undo" is only possible when the script has successfully 
finished. That means I have to reload the document.

Below is the test script that first changes the font and then creates an 
error afterwards.
I tested it with several font constants, always the same behaviour:
the font change can't be undone.

If I take out the error line and the script finishes successfully, undo 
works fine and the old font can be restored.
Is it possible that some "redo"-flags are not set correctly in case of 
"FCFontPrefs:Save()" ?

Best regards,
Jan

function SetDefaultFont(fontID,fontname,fontsize)
         local fontprefs=finale.FCFontPrefs()
         fontprefs:Load(fontID)
         local fontinfo=fontprefs:CreateFontInfo()
         fontinfo:SetSize(fontsize)
         fontinfo.Name=fontname
         fontprefs:SetFontInfo(fontinfo)
         fontprefs:Save()
end

SetDefaultFont(finale.FONTPREF_KEYSIG,"Times New Roman",24) --change to 
another font
test[1]=0  --gives an error as test was not initialized





More information about the JWLua mailing list