Skip to content

Mixin request for FCNoteEntryLayers #326

Open
@rpatters1

Description

@rpatters1

Is your feature request related to a problem? Please describe.
This issue arose due to a common and justifiable misunderstanding about the intent of the built-in eachentry and eachentrysaved functions. It is important for a Finale-Lua programmer to understand how these work, and for this reason they are open source. They are written in Lua, so you don't have to know C++ to understand them.

The basic problem is that the eachentry... functions create local instances of variables from which they feed entry instances back to the loop. If the loop saves those instances out to a table or other variable external to the loop, the underlying C++ structures will go out of scope when Lua garbage collection runs. If your code then accesses one of these instances, Finale crashes. The eachentry... functions facilitate one-by-one entry processing but should never be used for aggregate entry processing or analysis.

What's needed is an easy way to traverse entries, allowing them to be cherry picked and processed after the loop finishes.

Describe the solution you'd like
I propose adding an FCX mixin for FCNoteEntryLayers (or FCNoteEntryLayer, see below) that would allow it to have its own eachentry iterator function. Then you could do something like:

local entries = mixin.FCXNoteEntryLayers()
entries:LoadForRegion(finenv.Region())
for entry in entries:eachentry() do
   -- cherry-pick entries for later processing
end
-- process cherry-picked entries.
entries:SaveAll() -- if you made changes to the entries

Describe alternatives you've considered
The only other alternative I can think of is standard library functions, but a mixin seems like a better DX.

Additional context
The biggest issue is that FCNoteEntryLayers is not exported into Lua at the moment. So until that could be added to RGP Lua (and/or if we want to support this with JW Lua), we might need to make this a mixin on FCNoteEntryLayer and create a "fake" collection in Lua.

Another issue to be aware of is that this loop would traverse layers with the layer number as the top loop variable. Programmers would have to get used to a different sequence of entries than for the standard eachentry... functions, unless we wanted to write a lot of Lua code in the mixin to make it the same.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions