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. |
|
21st May 2005, 05:04 | #1 | Link |
Registered User
Join Date: Jul 2003
Location: India
Posts: 890
|
Facility to skip portions of script
In Avisynth script # symbol makes the parser to disregard the line. When a large number of statements are being tried for optimum results very often need to skip a large chunk of script arises. By meticulous planning and equating results to some symbols this is possible but immediately one statement is changed a chain of statements need some modifications. Functions can be specified but not always convenient. I am looking forward for a facility like /* */ of C++ may be /# or @# or &# and their inverses on a line by itself can ignore the code inbetween by the parser.
Yesterday I posted a similar request but today I did not find it in the topics. |
21st May 2005, 06:09 | #2 | Link | |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Re: Facility to skip portions of script
Quote:
Disabling code by commenting it out in general software development usually leads to maintainability problems. Refactoring and modularizing are good things. But, if you really must, one hack is to use quotes (or triple-quotes) and treat an entire section of a script as one big, unused string. |
|
21st May 2005, 07:21 | #3 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
could you elaborate on the triple quote thing? i don't get how it'd carry across lines.
btw, avisynth scripting, though often quite advanced, isn't software development. it's good to be able to "rem out" several lines when you're only talking about trying different things out on a clip. it'd also be nice for documenting useful scripts (so other people can use them) without having to put heaps of # everywhere. for example, i'm the only geek at work who really knows avisynth, though heaps of people would like to use it for simple things (NTSC to PAL comes up a lot). to have an instruction manual inside a script is useful in these cases, though it's not really important to have no #'s at the start of each line. more of a convenience thing i guess. hehe... i second vcmohan's request
__________________
sucking the life out of your videos since 2004 |
21st May 2005, 13:52 | #4 | Link | |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Quote:
Code:
mpeg2source("sample.d2v") # unused = """ \ addborders(16,0,0,0) subtitle("funny text") # normal comments don't interfere greyscale # \""" return last eval(unused) By doing so, you can enclose different parts of a script in quotation marks, and use these strings as quasi-functions. At times this may come handy for conditional executions and such. See here. stickboy wrote lots of useful stuff for AviSynth. Reading it is really worth it. - But if one doesn't mind bowing down to grab the money that's lying on the street, well ...
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
|
23rd May 2005, 16:31 | #6 | Link | |
Registered User
Join Date: Oct 2001
Location: france
Posts: 521
|
Quote:
If I take vb6 as an example, you don't have this option... so you are forced to use comment your block by starting ' which is kinda depressing... I do agree that the use of goto and labels leads to disastrous problem, but that's not the case for style commenting, as far I know. 2- Even with this argument taken (and proven as valid), I doubt that it will affect the stability of scripts, if such concept exists. Am I wrong? Now adding the corresponding comment style is possible in the actual parser and in the future (3.0) right? esby
__________________
http://esby.free.fr/ |
|
23rd May 2005, 17:22 | #7 | Link | ||
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Quote:
Quote:
Last edited by stickboy; 23rd May 2005 at 17:31. |
||
23rd May 2005, 22:59 | #8 | Link | |
Registered User
Join Date: Oct 2001
Location: france
Posts: 521
|
I agree with the explanation, except a few points...
Code:
# x = y y = z So you are merely talking of the usage of comments to take code out, no matter the type of comments used. I mean, the example you use can be done (and is done already) in avisynth. So it does not justify the absence of 'comment blocks'. Now give me just the counter example of what you say. (pascal style) Code:
(*** Removed code y := z x := z End of removed code ***) The ambiguity you describe is only possible by bad documentation practice to my eyes. Of course, nobody is perfect, but the point is not here. Quote:
Having a start & end comment type can help here, as you can format more easily comments, althought it is very relative and narrowed point of view... Of course, functionnal programming is a better approach. Now I usually create an avs script by modifying a model or template. When I use function, it is mainly to avoid rewriting existing code, not to maintain these scripts over time. These scripts have a relatively restricted utility over time. You can even consider that once there have been written and used, you'll almost never use them again, but that's my mere opinion. esby PS: I think that the one of the reason to the absence of comment blocks is that nobody ever requested them or estimated them to be avs scripting.
__________________
http://esby.free.fr/ |
|
24th May 2005, 03:35 | #9 | Link | |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Quote:
All I said was that using comments (whether single-line or multi-line) for the purpose of disabling code is in general a poor programming practice that can lead to maintainability problems. |
|
26th May 2005, 03:25 | #10 | Link |
Registered User
Join Date: Jul 2003
Location: India
Posts: 890
|
May be maintainability problems exist with this style of commenting out portions of script. but I find that just as in C++ coding it is useful in many cases, there is utility in having such a facility in Avisynth scripting also. Every facility can be misused, but that does not preclude having such a facility. Hope it will be introduced.
|
9th June 2007, 17:41 | #11 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,183
|
It is a time to return to this discussion.
IMO, block comments would be useful both for multi-line and single-line comments like C /* comment */ It also may be useful for editors like AvsP for of sliders or switching blocks. The implementation is quite easy (in tokenizer.cpp). The question is: what symbols to use as a comment. New avosynth must be compatible with old scripts. The possible candidates are: [ and ] or [# and #] May be some other. AvsP-compatibility is important too, but AvsP syntax may be changed IMO. For example, it is possible to use filter(param=[<"name",0,255>]5) instead of filter(param=[<"name",0,255,5>]). In this case brackets may be considered by new Avisynth as comment block. ?
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick I usually do not provide a technical support in private messages. |
10th June 2007, 02:27 | #12 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
I would hate to waste a good set of single bracketing characters. You never know when you might need them.
So I would prefer to go with a pair of characters like the [# ... #] or what most current languages seem to be using i.e good ol' /* ... */ |
10th June 2007, 09:18 | #13 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,183
|
After some playing I discover, that Didee example with triple quotes may be even more simple:
Code:
version() """ it is docstring comment block addborders(16,0,0,0) subtitle("funny text") # normal comments don't interfere greyscale """ return last But it can not be used in function parateters through. Looking to source I discover one more undocumented feature: __END__ statement for comments after end of code! (like Perl and Ruby) Code:
version() addborders(16,0,0,0) # normal comments don't interfere __END__ any lines after this end statement is a comment and not processed subtitle("funny text") greyscale return last
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick I usually do not provide a technical support in private messages. |
10th June 2007, 23:03 | #14 | Link |
Registered User
Join Date: Sep 2005
Location: 100011110010001000001 10000011111111000001
Posts: 221
|
Triple double quoted strings may appear in the script as values to assign in variables or pass to functions (especially when you want to make something a bit more elaborate with the runtime filters, or make an if..else block). Thus one cannot block-comment such sections of the script with this trick.
I believe a special double pair with its first character to be # is the best solution, because then only the part of the tokenizer that skips characters after the comment has to be modified. Some possible candidates: #/ ...... /# #{ ...... }# #< ...... ># #[ ...... ]#
__________________
AVSLib, a free extension library for Avisynth. Current version: 1.1.0 (beta), 14/05/2007. [ Home page | Download page ] Last edited by gzarkadas; 10th June 2007 at 23:04. Reason: minor corrections |
10th June 2007, 23:21 | #15 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Using a leading '#' will change the existing behaviour. Any script that happens to match the chosen pair would no longer work. Candidate pairs need to cause a systax error in the existing versions.
|
10th June 2007, 23:29 | #16 | Link | |
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
np: The Black Dog - Vir²l (Parallel)
__________________
now playing: [artist] - [track] ([album]) |
|
10th June 2007, 23:40 | #17 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,183
|
well, /* ... */ is not so bad (this combination is not possible in current version).
will it possible to comment inside a function? Code:
version() borders(0,/* add two top lines */ 2, -0,-0)
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick I usually do not provide a technical support in private messages. |
10th June 2007, 23:44 | #18 | Link | |
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
Will there be support for nested block comments? Those would simply need a counter in the skipping routine. And what should happen with stuff like "/*/" and "*/*"? np: Porn Sword Tobacco - Copyright The Universe (New Exclusice Olympic Heights)
__________________
now playing: [artist] - [track] ([album]) |
|
11th June 2007, 09:05 | #20 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Okay, I've been tinkerin' somewhat.
1. Having both nestable and first drop terminable comments is damn usefull. 2. [# #] I think looks ugly, the # char is to heavy. 3. [* *] seems to look more balanced to my eye. So currently I have /* */ as first drop terminable comments. i.e /* /* */ is valid. And [* *] as nestable terminable comments i.e. [* [* *] *] is valid. To keep things backwards compatible the # nuke to EOL style comment has priority. i.e # /* and # [* are valid. I'll put the code into CVS soonish and put up an avisynth.dll to try. Thoughts? |
Thread Tools | Search this Thread |
Display Modes | |
|
|