I got a program that can be controlled with applescript, so i build a simple repeat loop where i identify off-line clips
and remove them, the script exits with an errorcode and i understand why, but cannot resolve it.
tell application "OnTheAir Video"
tell front playlist
set x to clip count
update
repeat with y from 1 to x
set clipIsValid to is valid of clip y
if clipIsValid = 0 then
delete clip y
end if
end repeat
end tell
tell front playlist
play
end tell
end tell
I get a value of x from clip count(let’s say there are 10 clips in the playlist so x=10)
then repeat from 1 to x(10) with y increment…
Let’s say that clip#5 is off-line, the clipIsValid returns a 0 for clip 5, and will be deleted in playlist, remaining clips is now nine, when the 10th repeat loop is executed, it raises an error when ‘if valid’ function is called because it asks if clip#10 is valid while there are nine.
I’ve tried to dynamically update the value of x when a clip is deleted, but that didn’t work…
Could someone tell me on how to solve this?