JW Lua - Multiple Items

General notation questions, including advanced notation, formatting, etc., go here.

Moderators: Peter Thomsen, miker

User avatar
apkyburz
Posts: 179
Joined: Thu Jul 06, 2017 9:50 am
Finale Version: 26 (+TG, Pattsn, JW)
Operating System: Mac

Post by apkyburz » Wed Sep 23, 2020 1:04 am

Hey Folks,

I'm finally getting my feet wet on JW Lua.

Quick question: On this line:

local onlychangecertainnoteduration=1024

I want to add multiple items, but I can't get it to work. I'm trying

local onlychangecertainnoteduration=1536, 1024, 512
local onlychangecertainnoteduration=1536+1024+512 (this brings Lua in calcu-mode)
local onlychangecertainnoteduration=1536 & 1024 & 512

Could someone give me a hand?

Much appreciated,
A.P.


User avatar
motet
Posts: 8229
Joined: Tue Dec 06, 2016 8:33 pm
Finale Version: 2014.5,2011,2005,27
Operating System: Windows

Post by motet » Wed Sep 23, 2020 3:45 am

There's a JW Lua mailing list you should join.

http://jwmusic.nu/mailman/listinfo

User avatar
HaraldS
Posts: 229
Joined: Mon Dec 19, 2016 11:46 am
Finale Version: 25.5
Operating System: Windows

Post by HaraldS » Fri Sep 25, 2020 9:36 pm

There are two methods: either check for a range or run through a table which contains all possible values:

Code: Select all

print("Method #1: check whether the duration is within a range")
local SmallestEntryEDU = 1024
local HighestEntryEDU = 2048

for noteentry in eachentrysaved(finenv.Region()) do
    if ( noteentry.Duration >= SmallestEntryEDU ) and ( noteentry.Duration <= HighestEntryEDU) then
        print( "Entry #", noteentry.EntryNumber , " is within the range" )
    end
end

print("")
print("\rMethod #2: check if the duration occurs in a table")
local EntryEDUTable = { 1024, 2048, 4096 }

for noteentry in eachentrysaved(finenv.Region()) do
    for key, value in pairs( EntryEDUTable ) do
        if ( noteentry.Duration == value ) then
            print("Entry #", noteentry.EntryNumber, "'s duration occurs in the table")
        end
    end
end
Finale 3.0-25.5, German edition, Windows 7
trombonist, pianist, conductor / Recklinghausen, Germany

Post Reply