Last updated:

ReaScript Video Tutorial — Part. 9: Preventing Bugs

Scripts are powerful. But as Cockos developer’s Jeffos reminds me when I started:

With great power comes great responsibility

Uncle Ben, Spiderman

What you will learn in this lesson is very important, for all people who make scripts for REAPER.

In this video, you will see:

  • that scripts can set invalid values to a project
  • how to correct these invalid values
  • how to set new values, being sure that they are balid

It is not as complicated as it sounds: it is just basic conditions. Basic, but important!

Code Snippet:

-- A function to set an Item Fade-Out Length in security.
function SetItemFadeOut(item, item_len, fade_out_len)

	fade_in_len = reaper.GetMediaItemInfo_Value(item, "D_FADEINLEN")
	max_value = item_len - fade_in_len
	if fade_out_len > max_value then
		fade_out_len = max_value
	--[[ Optionnal
	if fade_out_len < 0
		fade_out_len = 0

	reaper.SetMediaItemInfo_Value(item, "D_FADEOUTLEN", fade_out_len)


Next videos will show you how and why using tables in ReaScript.

Help us translate the subtitles of this video in your language using !