Last active
December 7, 2024 08:55
-
-
Save cfillion/481cc1944b9c32c74b41 to your computer and use it in GitHub Desktop.
Test for the new AddRemoveReaScript API function added in REAPER v5.12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FILE_COUNT = 1 | |
| function generateFiles() | |
| local files = {} | |
| for index=1, FILE_COUNT do | |
| files[index] = string.format("%s/Scripts/DUMMY_%02d.lua", reaper.GetResourcePath(), index) | |
| end | |
| return files | |
| end | |
| function createFiles(files) | |
| for _,file in ipairs(files) do | |
| file = io.open(file, 'w') | |
| file:close() | |
| end | |
| end | |
| function removeFiles(files) | |
| for _,file in ipairs(files) do | |
| os.remove(file) | |
| end | |
| end | |
| function register(files) | |
| for index,file in ipairs(files) do | |
| local ret = reaper.AddRemoveReaScript(true, 0, file, index == FILE_COUNT) | |
| reaper.ShowConsoleMsg(string.format("registering #%02d -> %d\n", index, ret)) | |
| end | |
| end | |
| function unregister(files) | |
| for index,file in ipairs(files) do | |
| local ret = reaper.AddRemoveReaScript(false, 0, file, index == FILE_COUNT) | |
| reaper.ShowConsoleMsg(string.format("unregistring #%02d -> %d\n", index, ret)) | |
| end | |
| end | |
| files = generateFiles() | |
| if reaper.MB("Yes -> Register, No -> Unregister", "Test", 4) == 6 then | |
| createFiles(files) | |
| register(files) | |
| else | |
| unregister(files) | |
| removeFiles(files) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment