-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixin request for FCNoteEntryLayers
#326
Comments
I've already thought of an alternative that might be better: Wrap a table of Then our |
At the moment it's only possible to add a mixin to a Finale class that exists, and even though you can add a mixin to That could be changed, I guess, to use a dummy object like an |
I'm thinking a simple table wrapped as an object is the way to go. Using a fake class like |
I'm not familiar enough with how mixins work to comment on that, but +1 to the idea in general. |
Here is another idea that requires no work in this repo. (But does require an RGP Lua update.)
With this you could write the following: local entries = finale.FCNoteEntryCells()
for entry in eachentry(finenv.Region(), nil, entries) do
-- cherry pick entries into a table
end
-- process cherry picked entries
entries:SaveAll() -- if any changes needed to be saved. I think this can be implemented fairly easily. The devil is always in the details. |
Would a pure Lua solution be more preferable? That way any author who uses it doesn't need to bump the script's |
@rpatters1 Any further thoughts on this? If you still want a Lua solution, I can start working on it. |
I think a Lua solution makes sense. My original idea of using But those are just ideas. Feel free to be creative. |
Do you need a similar thing done for |
The only class that has the referencing issue is As for
The only issue I see is that the underlying |
I should add that |
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
andeachentrysaved
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. Theeachentry...
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 forFCNoteEntryLayers
(orFCNoteEntryLayer
, see below) that would allow it to have its owneachentry
iterator function. Then you could do something like: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 onFCNoteEntryLayer
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.The text was updated successfully, but these errors were encountered: