Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.


Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Thread Tools Search this Thread Display Modes
Old 25th July 2015, 23:08   #1  |  Link
I'm the Doctor
Join Date: Jan 2004
Posts: 1,512
Script parsing bug?

I've found some inconsistencies happening with Avisynth 2.6.0 when I accidentally miss out a . between keywords.

I was expecting none of the below to work, since I have omitted a . between the crop and the info, but they all work with inconsistent results:

version.crop(0,0,0,0)info # works as if I had typed .info
return version.crop(0,0,0,0)info # returns version WITHOUT info
q=version.crop(0,0,0,0)info # error: 'I don't know what "info" means'
q=version.crop(0,0,0,0)info # applies info to the implicit last blankclip, but not to q
EDIT: All of the above are explained if the parser is imagining an implicit newline between the crop(...) and the info. Maybe that's what was intended, though I'd have thought an error in all cases would be more helpful.
My AviSynth filters / I'm the Doctor

Last edited by davidhorman; 25th July 2015 at 23:27.
davidhorman is offline   Reply With Quote
Old 25th July 2015, 23:52   #2  |  Link
Retried Guesser
raffriff42's Avatar
Join Date: Jun 2012
Posts: 1,377
All basic AviSynth scripting statements have one of these forms:
  1. variable_name = expression
  2. expression
  3. return expression
(Two higher-level constructs also exist - the function declaration and the try..catch statement.)

As a shorthand, a bare expression as the final statement in a script (or script block) is treated as if the keyword return was present.
is equivalent to
Last=version.crop(0,0,0,0) # (1. variable_name = expression)
Last.Info # (2. expression)
return Last # (implied)
(adding implicit Last and return)

return version.crop(0,0,0,0)info
is equivalent to
return version.crop(0,0,0,0) # (3. return expression )
(Info is simply ignored here)

As you guessed, newlines are not required to terminate a statement, which I find makes the code harder to read, but oh well.

q=version.crop(0,0,0,0)info # error: 'I don't know what "info" means'
is equivalent to
q=version.crop(0,0,0,0) # (1. variable_name = expression)
???.Info # (????)
(missing Last argument to Info) (shouldn't the error message be "invalid argument to function Info" then?)

is equivalent to
Last=blankclip # (1. variable_name = expression)
q=version.crop(0,0,0,0) # (1. variable_name = expression)
Last=Last.info # (2. expression)
return Last # (implied)
((Gavino? What have I missed?))

Last edited by raffriff42; 26th July 2015 at 01:12.
raffriff42 is offline   Reply With Quote
Old 26th July 2015, 09:53   #3  |  Link
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,380
Originally Posted by raffriff42 View Post
(missing Last argument to Info) (shouldn't the error message be "invalid argument to function Info" then?)
Because there are no parentheses after "info", and there is no valid implicit function argument, it is treated as a variable here, hence the error message.
q=version.crop(0,0,0,0)info() would produce "invalid argument ..."

On the subject of statement separators, see this thread.
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 00:11.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.