PDA

View Full Version : How to process NULL clip?


Fizick
6th January 2008, 15:25
Recently I discover rarely used and not very documented keyword NULL as dummy clip substitution.

But how to detect and properly process NULL clip in plugin?

Example Script:
...
MVFlow(..., pelclip=null)


If I do not define pelclip:

MVFlow(...)

then I can use agrs[5].IsDefined() to detect if pelclip was given. Current code is:

(args[5].Defined() ? args[5].AsClip() : 0), // pelclip

But args[5].AsClip() == NULL (or 0) do not work for NULL clip.
And seems NULL clip is not 0.

squid_80
6th January 2008, 16:01
I think NULL technically has a value in this case: 0, which is an integer. So args[5].Defined() returns true, but args[5].AsClip() returns nothing because it's not a clip. args[5].AsInt() will return 0.
Try dropping Defined() and just use AsClip().
args[5].AsClip() // Should return the clip or 0 if args[5] is not a clip.

It can trigger an ASSERT while debugging but that's just to make sure you know what you're doing.