PDA

View Full Version : a syntax error


leonid_makarovsky
2nd December 2004, 08:58
I'm trying to write my own function blank_clip for ease of use. It takes clip, start point, end point and the color and blanks the whole area. Here it is the whole script:

clip = AVISource("L:\CrossPurposes.avi")
beginning = blank_clip(clip, 276, 276, $000000)
middle = Trim(clip, 277, 157265)
end = blank_clip(clip, 157266, 157267, $000000)
clip = beginning ++ middle ++ end
return clip

function blank_clip(clip myclip, int start, int finish, int color)
{
thepart = Trim(myclip, start, finish)
blankout = BlankClip(thepart, length = Framecount(thepart), pixel_type="YUY2", color)
return blankout
}

When I load it to VirtualDub, it says:
Script error: the named argument "length" was passed more than once to BlankClip
line 12...

I've been banging against the wall for a while now before I decided to post here. I'm sure there's some dumb small mistake that I'm overlooking. Thanks.

And also how can I specify the default values to omit passing arguments. Like in C++ I can declare the function void func(int arg1, int arg2 = 0); Then I can just call func(arg1) without passing arg2. Is there any way to do so in AVISynth?

--Leonid

stickboy
2nd December 2004, 11:36
Originally posted by leonid_makarovsky
When I load it to VirtualDub, it says:
Script error: the named argument "length" was passed more than once to BlankClip
line 12...The error message is vague and probably could be improved, but the problem is you gave a positional argument after a named one:blankout = BlankClip(thepart, length = Framecount(thepart), pixel_type="YUY2", color)Note that you didn't pass color as a named argument; therefore AviSynth tried to assign it to BlankClip's second parameter--length--and hit the collision.

The line should be:
blankout = BlankClip(thepart, length=Framecount(thepart), pixel_type="YUY2", color=color)
And also how can I specify the default values to omit passing arguments. Like in C++ I can declare the function void func(int arg1, int arg2 = 0); Then I can just call func(arg1) without passing arg2. Is there any way to do so in AVISynth?# Parameters named in quotes are optional.
function foo(int "optional")
{
optional = Default(optional, someValue)
}Look at existing scripts for some examples (tooting my own horn: my AviSynth scripts (http://www.avisynth.org/stickboy/) (the JDL_Blackout function might be useful to you)).

leonid_makarovsky
2nd December 2004, 17:44
Everything worked. Thank you very much.

--Leonid