[JW Lua] Page/Part questions

Jari Williamsson jari.williamsson at mailbox.swipnet.se
Mon Sep 23 20:26:34 CEST 2013


On 2013-09-23 15:15, Charles O. Lawrence wrote:
> Should not the constant PARTID_SCORE be finale.PARTID_SCORE in JWLua
> (namespace context required)?

You're absolutely right! I wrote the code in the e-mail message without 
any testing.

> It would be nice if the script you provided
> for showing constants printed the name and value of the constant.

An updated version of that script is attached to this post. The only 
line that has changed is the print() statement.

> Why are
> PARTID_CURRENT and PARTID_UNKNOWN both equal to -1?  When would you use an
> unknown part?

Good questions... I just use PARTID_UNKNOWN internally for an unknown 
switchback reference. I'll need to clean this up, it's confusing. Don't 
use PARTID_UNKNOWN, I'll remove support for it in the next beta.

> Sometimes you need to generate parts to make sure you have all of them and
> that they are up-to-date.  Is there a way to do this in JWLua?

Unfortunatelly not. The PDK can't do much about part generation. Also, 
Finale prevents the PDK to make changes to the part name.


Best regards,

Jari Williamsson
-------------- next part --------------
function plugindef()
   -- This function and the 'finaleplugin' namespace
   -- are both reserved for the plug-in definition.
   finaleplugin.NoStore = true
   finaleplugin.Author = "Jari Williamsson"
   finaleplugin.CategoryTags = "Debug, Development, Diagnose, UI"
   return "List JW Lua Constants", "List constants", "Lists the constants available to JW Lua."
end



-- Show dialog

local dialog = finenv.UserValueInput()

dialog.Title = "List JW Lua Constants"

dialog:SetTypes("String")

dialog:SetDescriptions("Search string (empty to list all):")



local returnvalues = dialog:Execute()

if returnvalues == nil then return end

local pattern = returnvalues[1]



local result = {}



-- Search for constants

for k,v in pairs(_G.finale) do

    if string.find(k, "__propget") == 1 and (type(v) == "table") then

        for k1, v1 in pairs(v) do

            if string.find(k1, returnvalues[1]) or returnvalues == "" then

                table.insert(result, k1)                

            end

        end

    end

end



-- Present sorted result:

table.sort(result)

print("Searching for <", pattern, "> in JW Lua constants:")

for k, v in pairs(result) do

    print(v, "=", _G.finale[v])

end



More information about the JWLua mailing list