File tree 2 files changed +41
-1
lines changed
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -1022,7 +1022,7 @@ function mixin_public.eachentry(region, layer)
1022
1022
local c = mixin .FCMNoteEntryCell (measure , region :CalcStaffNumber (slotno ))
1023
1023
c :SetLoadLayerMode (layertouse )
1024
1024
c :Load ()
1025
- return function ()
1025
+ return function ()
1026
1026
while true do
1027
1027
i = i + 1 ;
1028
1028
local returnvalue = c :GetItemAt (i - 1 )
Original file line number Diff line number Diff line change
1
+ -- Author: Robert Patterson
2
+ -- Date: January 20, 2024
3
+ --[[
4
+ $module __FCMBase
5
+
6
+ ## Summary of Modifications
7
+ - Add method _FallbackCall to gracefully allow skipping missing methods in earlier Lua versions
8
+ ]] --
9
+ local mixin = require (" library.mixin" )
10
+ local mixin_helper = require (" library.mixin_helper" )
11
+
12
+ local class = {Methods = {}}
13
+ local methods = class .Methods
14
+
15
+
16
+ --[[
17
+ % _FallbackCall
18
+
19
+ Checks the existence of a class method before calling it. If the method exists, it returns
20
+ as expected. If the method does not exist, it returns the fallback_value. This function allows
21
+ a script to call a method that does not exist in earlier versions of Lua (specifically, in JW Lua)
22
+ and get a default return value in that case.
23
+
24
+ @ self (userdata) The class instance on which to call the method.
25
+ @ method_name (string) The name of the method to return.
26
+ @ fallback_value (any) The value that will be returned if the method does not exist. If this value is `nil`, the function returns `self`.
27
+ @ additional_parameters (...) The additional parameters of the method.
28
+ ]]
29
+ function methods :_FallbackCall (method_name , fallback_value , ...)
30
+ if not self [method_name ] then
31
+ if fallback_value ~= nil then
32
+ return fallback_value
33
+ end
34
+ return self
35
+ end
36
+
37
+ return self [method_name ](self , ... )
38
+ end
39
+
40
+ return class
You can’t perform that action at this time.
0 commit comments