Internal functions/Boolean functions

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(Expand description of Defined())
 
(make redirect)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
== Boolean functions ==
+
#REDIRECT [[Internal_functions#Boolean_functions]]
 
+
These functions return true or false, if the condition that they test holds or not, respectively.
+
 
+
* {{ScriptFunction|IsBool||IsBool(var)}}
+
: Tests if ''var'' is of the bool type. ''var'' can be any expression allowed by the [[AviSynth Syntax]].
+
: ''Examples:''
+
b = false
+
IsBool(b) = true
+
IsBool(1 < 2 && 0 == 1) = true
+
IsBool(123) = false
+
 
+
* {{ScriptFunction|IsClip||IsClip(var)}}
+
: Tests if ''var'' is of the clip type. ''var'' can be any expression allowed by the [[AviSynth Syntax]].
+
: ''Examples:''
+
c = [[AviSource]](...)
+
IsClip(c) = true
+
IsClip("c") = false
+
 
+
* {{ScriptFunction|IsFloat||IsFloat(var)}}
+
: Tests if ''var'' is of the float type. ''var'' can be any expression allowed by the [[AviSynth Syntax]].
+
: ''Examples:''
+
f = [[Internal_functions/Numeric_functions|Sqrt]](2)
+
IsFloat(f) = true
+
IsFloat(2) = true  # ints are considered to be floats by this function
+
IsFloat(true) = false
+
 
+
* {{ScriptFunction|IsInt||IsInt(var)}}
+
: Tests if ''var'' is of the int type. ''var'' can be any expression allowed by the [[AviSynth Syntax]].
+
: ''Examples:''
+
IsInt(2) = true
+
IsInt(2.1) = false
+
IsInt(true) = false
+
 
+
* {{ScriptFunction|IsString||IsString(var)}}
+
: Tests if ''var'' is of the string type. ''var'' can be any expression allowed by the [[AviSynth Syntax]].
+
: ''Examples:''
+
IsString("test") = true
+
IsString(2.3) = false
+
IsString([[Internal_functions/Conversion_functions|String]](2.3)) = true
+
 
+
* {{ScriptFunction|Exist|v2.07|Exist(filename)}}
+
: Tests if the file specified by ''filename'' exists.
+
: ''Examples:''
+
filename = ...
+
clp = Exist(filename) ? [[AviSource]](filename) : [[Internal_functions/Control_functions|Assert]](false, "file: " + filename + " does not exist")
+
 
+
* {{ScriptFunction|Defined||Defined(var)}}
+
: Tests if ''var'' is defined. Can be used inside [[Script_functions]] to test if an optional argument has been given an explicit value.
+
: More formally, the function returns false if its argument (normally a function argument or variable) has the void ('undefined') type, otherwise it returns true.
+
: ''Examples:''
+
b_arg_supplied = Defined(arg)
+
myvar = b_arg_supplied ? ... : ...
+
 
+
----
+
Back to [[Internal functions]].
+
  
 
[[Category:AviSynth_Syntax]]
 
[[Category:AviSynth_Syntax]]
 
[[Category:Scripting_Basics]]
 
[[Category:Scripting_Basics]]

Latest revision as of 03:53, 17 September 2014

  1. REDIRECT Internal_functions#Boolean_functions
Personal tools