Closed SuggonM closed 8 months ago
Yes I was a little bit confused by it too.
If (!VarExist("MyVar"))
that means MyVar hasn't been created at all. The lowest form of nothingness.
If (VarExist("MyVar"))
there are 2 possibilities:
MyVar has been created, but hasn't been set to anything. Kind of like a null pointer I guess. In this case Defined(MyVar)==false
. This is what convenience function Default()
checks for. If you are inside your own custom function and you want to check if the user passed an optional argument, this is the check you want. By the way Defined(MyVar)==false
is equivalent to MyVar==Undefined()
.
MyVar has been created, and has been set to something like a string, int etc. The highest form of somethingness.
Operators like ==
!=
>
<
etc. can only compare two of the same type which are Defined(). So you can't compare an Undefined() with a string or an int, or another Undefined(). Plus, if your custom function has a generic "val" type argument then you need to use IsInt(), IsString() etc. to check you're comparing two of the same type.
It seems you'd want this: pad_t = VarExist("pad_t") && IsInt(pad_t) ? pad_t : 50
edit: I should mention the IsInt(pad_t)
would normally throw an error if pad_t does not exist, but short circuit evaluation is probably avoiding that.
May I get more descriptive examples of
Default
,Defined
andVarExists
functions?At this point, I've explored all the possible ways to make a variable check using them, but none seemed to work. Either the variable exists and remains as-is untouched, or the variable doesn't exist and throws the error
I don't know what '<variable>' means.
, which kindof defeats the point of var-exist check.Following is the code I'm using. On the "client" side, all the desired variables are passed as global - otherwise omitted. On the "author" side, it checks if the variables exist - otherwise they default to
50
.I'm also using the latest version of AviSynth+ and AvsPmod. But looking at the documentations and few other decade-old forums, they seemed to be working fine on the users' side (for example,-EDIT)).