View Single Post
Old 11-03-2019, 08:22 PM   #581
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by deeb View Post
per example:
Code:
doSomething = function(arg)
-- doSomething 
end

local menus ={}
for i=1, 20 do
    table.insert(menus, {"line"..1, doSomething(i)} )
end
...
How would you solve this?

Thanks a lot!
v3 will allow you to specify parameters when you create the menu just like you can with Buttons, but in the meantime you can use a closure - a wrapper function that calls the "real" function with the parameter you want.

Instead of:
Code:
local menus = {
    
    {title = "File", options = {
        {"New", mnu_file.new},
Do:
Code:
local menus = {
    
    {title = "File", options = {
        {"New", function() mnu_file.new(someParameter) end},
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote