fix mistaken "do not roll" conclusion in TransportFSM::compute_should_roll()
[ardour.git] / scripts / _remember_file.lua
1 ardour {
2         ["type"] = "EditorAction",
3         name = "File Name Test",
4         author = "Ardour Lua Taskforce",
5         description = [[Example Plugin to show to to select a file and remember the most recently used file.]]
6 }
7
8 function factory ()
9         local file_name_testscript_last_filename -- this acts as "global" variable, use a unique name
10         return function ()
11                 print (file_name_testscript_last_filename) -- debug
12
13                 --set filename to most recently used, fall back to use a default
14                 local fn = file_name_testscript_last_filename or ARDOUR.LuaAPI.build_filename (Session:path (), Session:name () .. ".ardour")
15
16                 -- prepare a dialog
17                 local dialog_options = {
18                         { type = "file", key = "file", title = "Select a File",  path = fn }
19                 }
20
21                 -- show dialog
22                 local od = LuaDialog.Dialog ("title", dialog_options)
23                 local rv = od:run()
24
25                 if rv then
26                         -- remember most recently selected file
27                         file_name_testscript_last_filename = rv['file']
28                         LuaDialog.Message ("title", "set path to " .. file_name_testscript_last_filename, LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
29                 else
30                         -- unset most recently used filename on dialog "cancel"
31                         file_name_testscript_last_filename = nil
32                 end
33
34                 od = nil
35                 collectgarbage ()
36         end
37 end