<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    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
    ... ?<br>
    <br>
    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. <br>
    Maybe Jari knows better or maybe even he doesn't know what happens
    within in Finale in these cases.<br>
    <br>
    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 ? <br>
    <br>
    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.)<br>
    <br>
    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.<br>
    It's also possible to change the category assignment later on, so it
    looks repairable.<br>
    <br>
    local catdef=finale.FCCategoryDef()<br>
    catdef:Load(-1)  --!!!negative, it also possible to use higher
    unavailable category IDs like catdef:Load(1000)<br>
    local exprdef = finale.FCTextExpressionDef()<br>
    local textstr = finale.FCString()<br>
    textstr.LuaString = "test"<br>
    exprdef:SaveNewTextBlock(textstr) <br>
    exprdef:AssignToCategory(catdef)<br>
    print(exprdef:SaveNew()) --returns true<br>
    <br>
    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).<br>
    local staff=1<br>
    local measure=1<br>
    local measurepos=0<br>
    local expressionID=1<br>
    local expression=finale.FCExpression()<br>
    expression:SetMeasurePos(measurepos)<br>
    local cell = finale.FCCell(measure,staff)<br>
    local textexpr=finale.FCTextExpressionDef()<br>
    textexpr:Load(expressionID)<br>
    expression:AssignTextExpressionDef(textexpr)<br>
    expression:SetScoreAssignment(true)<br>
    expression:SetLayerAssignment(-3) --!!!!negative<br>
    print(expression:SaveNewToCell(cell)) --returns true<br>
    <br>
    Jan<br>
    <br>
  </body>
</html>