Log in

View Full Version : Using RETURN in Scripts


Asrial
18th October 2003, 08:11
I don't know where to properly search for information on this.

I'm curious as to what all this does for people when they use it.

IE: they have their script and every so often (or usually at the end of a set of functions, they have a 'return' popped in).

Also, how can I force all of a clip (up to a certain point in the script) to be considered a specific name?

I know how to do it with NAME = TRIM(blahblahblah) but I don't know how to do it when I want the entire clip to be NAME.

I'm thinking the RETURN function and this might be related.

Anyways, can someone point me in the right direction to find out more about using RETURN? Don't just say "the avisynth manual" because I don't know where specifically to look.

stickboy
18th October 2003, 10:50
When you call a function, that function generates some result. (Usually this result is a clip, although it can be a number, a string, etc.) A function indicates what the result is via the return statement.

The caller of the function can assign this return value to a variable. If the function returns a clip and if the caller does not explicitly assign that clip to a variable, AviSynth automatically assigns it to the special variable last.

Every AviSynth script must return a clip. If a script does not have an explicit return statement, then AviSynth adds an implict return last to the end of the script. (I believe AviSynth does the same thing for functions. I prefer using explicit return statements in functions as a matter of style.)

Hence, the script:AVISource("foo.avi")
Trim(0, 500)is really shorthand for:last = AVISource("foo.avi")
last = last.Trim(0, 500)
return lastOriginally posted by Asrial:
Also, how can I force all of a clip (up to a certain point in the script) to be considered a specific name?By now, hopefully you should have an idea what to do: Adding a line:name = lastto the appropriate spot in your code should do what you want.