Old 04-12-2021, 12:37 AM   #1
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default How to check if a item still exists?

is there a API to check if a item/track/take anything still exist?

(the thing existed in the start of the script but it might be (proposaly) deleted)
daniellumertz is offline   Reply With Quote
Old 04-12-2021, 04:03 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Code:
function DoesItemExist(Item)
  return pcall (reaper.IsMediaItemSelected, Item)
end
This returns true, if the MediaItem exists or false if it doesn't exist anymore.
If false, the second returnvalue holds the error-message that happened.

(This function doesn't check, if Item is a valid MediaItem, but you can add this using reaper.ValidatePtr() )

Edit: I think, I'll add that to Ultraschall-API as well. This could be helpful I think.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by Meo-Ada Mespotine; 04-12-2021 at 04:09 AM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-12-2021, 04:33 AM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

ValidatePtr API function:


https://github.com/ReaTeam/ReaScript...20validity.lua
X-Raym is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.