[JW Lua] Can JW Lua scripts mess up documents that can't be repaired afterwards ?

Jan Angermüller jan at angermueller.com
Wed Jan 4 17:41:47 CET 2017


Siill Michael Johnson from MM insists on plugins being dangerous to 
Finale, but we haven't found any JW Lua scripts that prove this. Hm ... ?

I have started collecting situations that are possibly dangerous, but I 
can't tell if they are really unrepairable and/or if they affect the 
document in a negative way at all.
Maybe Jari knows better or maybe even he doesn't know what happens 
within in Finale in these cases.

Maybe it would be an idea to make at least some cases a bit more safe in 
JW Lua by adding for example an unsigned/signed range check within the 
JW Lua PDK where it's definitely necessary ?

There are probably not too many cases where it is necessary (and 
possibly dangerous), but for example the following two cases look rather 
dangerous too me. They are about negative category IDs and negative 
layer numbers. (And don't tell me that they are rather unlikely to 
happen ;-) By using faulty parameters/variables/constants they are 
possible and don't look as obvious as in the code snippets below.)

1.) It's possible to load negative or unexisting categories and to 
assign them to new text expressions. The expression will be added and 
appears in the "Show all" and "Miscellaneous" category, but still it 
internally has the wrong category ID. Or does it mean that everything 
that is in an unavailable category is in the "Miscellaneous" category 
and that it doesn't do any harm to the Finale document ? I don't know.
It's also possible to change the category assignment later on, so it 
looks repairable.

local catdef=finale.FCCategoryDef()
catdef:Load(-1)  --!!!negative, it also possible to use higher 
unavailable category IDs like catdef:Load(1000)
local exprdef = finale.FCTextExpressionDef()
local textstr = finale.FCString()
textstr.LuaString = "test"
exprdef:SaveNewTextBlock(textstr)
exprdef:AssignToCategory(catdef)
print(exprdef:SaveNew()) --returns true

2.) It's possible to assign an expression to an unexisting layer. The 
expression will not be visible, but it's in the memory and can be 
changed to other layers later on (->seems to be repairable).
local staff=1
local measure=1
local measurepos=0
local expressionID=1
local expression=finale.FCExpression()
expression:SetMeasurePos(measurepos)
local cell = finale.FCCell(measure,staff)
local textexpr=finale.FCTextExpressionDef()
textexpr:Load(expressionID)
expression:AssignTextExpressionDef(textexpr)
expression:SetScoreAssignment(true)
expression:SetLayerAssignment(-3) --!!!!negative
print(expression:SaveNewToCell(cell)) --returns true

Jan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20170104/75896fc6/attachment.htm>


More information about the JWLua mailing list