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)
		
			+ Reply to Thread
			
		
		
		
			
	
	
				Results 1 to 6 of 6
			
		- 
	
- 
	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, 15:08
- 
  Issue with an Avisynth interpolation function and related questionsBy abolibibelot in forum Video ConversionReplies: 9Last Post: 16th Dec 2018, 00:55
- 
  Avisynth Loop functionBy pooksahib in forum Video ConversionReplies: 16Last Post: 29th May 2016, 13:03
- 
  Using avisynth's 'amplify' functionBy pooksahib in forum Video ConversionReplies: 53Last Post: 25th May 2016, 03:23
- 
  avisynth: is there an alternative function to the SmoothFPS2By marcorocchini in forum Newbie / General discussionsReplies: 1Last Post: 1st Nov 2014, 12:03


 
		
		 View Profile
				View Profile
			 View Forum Posts
				View Forum Posts
			 Private Message
				Private Message
			 
 
			
			

 Quote
 Quote