[JW Lua] FCLuaIterator problem: no entries detected if EndMeasurePos==StartMeasurePos

Robert Patterson robert at robertgpatterson.com
Sat May 28 14:59:59 CEST 2022


Rats, forget what I just said. The end position is definitely included in
the region. The bug is in FCLuaIterator, so now I *am* inclined to fix it.

Example: selecting half a 4/4 bar gives 2047 as the end measure position.

On Sat, May 28, 2022 at 7:53 AM Robert Patterson <
robert at robertgpatterson.com> wrote:

> Okay, I suddenly realized that we are discussing a region where the end
> position is equal to the start position. (I guess I needed my morning
> coffee to realize this.) A selected region goes from the start position to
> (but not including) the end position. If start == end, then the region is
> empty. The bug here (if we want to call it that) is actually in the
> built-in functions eachentry and eachentrysaved which do not recognize that
> the region is empty. (Specifically it's the FCMusicRegion:IsEntryPosWithin
> function that should return false in this case.)
>
> Think about it: the Finale UI does not allow selecting a region where
> start == end.
>
> I am certainly not going to change eachentry or eachentrysaved. And I am
> disinclined to change FCLuaIterator, so perhaps I'll add a clarifying
> comment.
>
>
> On Sat, May 28, 2022 at 7:01 AM Simon Leclerc <simon at prodsl.ca> wrote:
>
>> After testing it, I arrive to the same conclusion. I use FCLuaIterator()
>> often. Just never had to specify a region of 0-0.
>>
>> The behaviour is not the same with “in eachentry” which will see an entry
>> positioned at zero in a region of 0-0.
>>
>>
>>
>>
>>
>>
>>
>> ¯\_(ツ)_/¯
>>
>> Simon Leclerc
>> 60, Mirabelle
>> Ste-Agathe-des-Monts, Québec
>> J8C 0W9
>> simon at prodsl.ca
>>
>>
>>
>>
>> On May 27, 2022, at 20:53, Robert Patterson <robert at robertgpatterson.com>
>> wrote:
>>
>> I would be interested to hear from anyone else on this issue. I know
>> someone said they were using FCLuaInterator. This would potentially be a
>> breaking change.
>>
>> On Fri, May 27, 2022 at 11:02 AM Jan Angermüller <jan at angermueller.com>
>> wrote:
>>
>>> Robert,
>>>
>>> I noticed a problem with FCLuaIterator, probably caused by a < instead
>>> of <= operator.
>>>
>>> According to the documentation the ForEachEntry operator should work
>>> like the each operator on entries.
>>>
>>> But: if you set the EndMeasurePos==StartMeasurePos (e.g. both 0 in the
>>> code below), then ForEachEntry won't detect entries on that measure
>>> position. The each operator also shows all entries from that measure
>>> position.
>>> I.e. you always have to set EndMeasurePos to at least  StartMeasurePos+1
>>> to make ForEachEntry work for a single measure position.
>>>
>>> Test code: (should show all entries with articulations in measure 1
>>> staff 1 measure position 0)
>>>
>>> function ArticulationCallback(e)
>>>     print(e.MeasurePos)
>>> end
>>>
>>>     local region=finale.FCMusicRegion()
>>>     region.StartMeasure=1
>>>     region.EndMeasure=1
>>>     region.StartStaff=1
>>>     region.EndStaff=1
>>>     region.StartMeasurePos=0
>>>     region.EndMeasurePos=0 --- when it is set to 1, it will work. When
>>> it's set to 0, it won't show any entries.
>>>     local iterator = finale.FCLuaIterator()
>>>     iterator:AddEntryFilter(finale.LIEFILTER_ARTICULATIONFLAG,
>>> finale.LILOGIC_AND)
>>>     iterator:ForEachEntry(region,ArticulationCallback)
>>>
>>> Could you please fix this in the next update?
>>> Or - should we keep it like this for compatibility reasons - add a line
>>> to the documentation.
>>>
>>> Jan
>>> _______________________________________________
>>> JWLua mailing list
>>> JWLua at jwmusic.nu
>>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>>
>> _______________________________________________
>> JWLua mailing list
>> JWLua at jwmusic.nu
>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
>>
>> _______________________________________________
>> JWLua mailing list
>> JWLua at jwmusic.nu
>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20220528/4d244855/attachment.htm>


More information about the JWLua mailing list