APITest();
reaper.APITest()
RPR_APITest()
nil
before passing to functions.
Main_OnCommand(40746, 0);
RPR_SetExtState("utility", "someflag", "2", True)
val=RPR_GetExtState("utility", "someflag") # even if called after REAPER is closed and reopened, val will be equal to "2"
There are also API functions for manually creating undo points, as well as API functions to Undo and Redo previous points.
The best way to manually create an undo point for your script is to call Undo_BeginBlock() before most of your code, and Undo_EndBlock() after your code finishes.
Undo_BeginBlock
with Undo_EndBlock
. If you call Undo_BeginBlock
and then fail to call Undo_EndBlock
, an undo block will be left open, which may cause undesired undo behaviors.
Undo_EndBlock
is a bitmask of what you would like to add to the undo state. If you are simply calling other actions
(via Main_OnCommand
or similar functions), this should be 0. If you modify the state of the project directly, it's safest to set the bitmask
to -1. A more specific combination of flags may be an optimization, depending on what your script is doing.
Undo_EndBlock
a valid (non-empty) descriptive string.
reaper.Undo_BeginBlock()
m = reaper.GetMasterTrack(0)
reaper.TrackFX_GetByName(m, "ReaEQ", 1)
reaper.Undo_EndBlock("Add ReaEQ FX to the master track", -1)
function run()
is_new,name,sec,cmd,rel,res,val = reaper.get_action_context()
if is_new then
reaper.ShowConsoleMsg(name .. "\nrel: " .. rel .. "\nres: " .. res .. "\nval = " .. val .. "\n")
end
reaper.defer(run)
end
function onexit()
reaper.ShowConsoleMsg("<-----\n")
end
reaper.defer(run)
reaper.atexit(onexit)