I know Avisynth function parameters can have default values. For instance, the Subtitle filter can be used in the short form
Subtitle(clip,"text")
without giving any additional arguments (x, y...) because they already have default values.
But I do not know how to define default values for my own functions. I have read the guides, searched the Web, etc. but couldn't find anything that works for me.
As an example, say we have the following simple function, which adds or subtracts 2 numbers, depending on the conditional parameter Plus.
Function PlusMinus(int n1, int n2, bool Plus)
{
result = (Plus==True) ? n1+n2 : n1-n2
return result
}
How do we define "Plus" to be True as default?
So that we can use
n3 = PlusMinus(n1, n2)
as the short form of
n3 = PlusMinus(n1, n2, True)
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 6 of 6
Thread
-
-
Plus = default(Plus, true)
See http://avisynth.nl/index.php/Internal_functions/Default#Default -
Thank you.
Do you mean coding the function like this?
Function PlusMinus(int n1, int n2, bool Plus)
{
Plus = default(Plus, true)
result = (Plus==True) ? n1+n2 : n1-n2
return result
}
Because it isn't working
AviSource("J:\01.avi").Trim (525, PlusMinus(525, 100, True)) gives no error
AviSource("J:\01.avi").Trim (525, PlusMinus(525, 100)) gives "Invalid arguments to function PlusMinus" -
I have found this work
Function PlusMinus(int n1, int n2, bool "Plus")
{
Plus = default(Plus, true)
result = (Plus==True) ? n1+n2 : n1-n2
return result
}
ie, defining the parameter as bool "Plus", instead of just bool Plus
The quotation marks did the trick here. -
Similar Threads
-
How to use 64bit avisynth plugins in vapoursynth with the Eval function?
By danfgtn in forum Newbie / General discussionsReplies: 3Last Post: 18th Feb 2019, 14:08 -
Issue with an Avisynth interpolation function and related questions
By abolibibelot in forum Video ConversionReplies: 9Last Post: 15th Dec 2018, 23:55 -
Avisynth Loop function
By pooksahib in forum Video ConversionReplies: 16Last Post: 29th May 2016, 12:03 -
Using avisynth's 'amplify' function
By pooksahib in forum Video ConversionReplies: 53Last Post: 25th May 2016, 02:23 -
avisynth: is there an alternative function to the SmoothFPS2
By marcorocchini in forum Newbie / General discussionsReplies: 1Last Post: 1st Nov 2014, 11:03