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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 31st December 2011, 04:07   #1  |  Link
vampiredom
Registered User
 
Join Date: Aug 2008
Posts: 233
Referenced variables in AviSynth?

Many other scripting languages allow referenced variables; so that a function can modify an existing variable – or a large variable can be passed without needing to duplicate it in memory. For example:

For a case where I'd like to modify the value of "foo", it would be convenient to be able to write [something like]:

Code:
FunctionName(\foo)
instead of:

Code:
foo = FunctionName(foo)
Is there any such way to do something like in AviSynth? I doubt there is, but I figured I'd ask the question here to see if anybody knows any way by which a function can alter a pre-defined variable.
vampiredom is offline   Reply With Quote
Old 31st December 2011, 20:31   #2  |  Link
gyth
Registered User
 
Join Date: Sep 2011
Posts: 86
http://avisynth.org/mediawiki/Grammar
Functions always produce a new value and never modify an existing one. What that means is that all arguments to a function are passed "by value" and not "by reference"; in order to alter a variable's value in AviSynth script language you must assign to it a new value.

If you can give an example of what you are trying to do, someone can probably come up with an equivalent solution.
gyth is offline   Reply With Quote
Old 31st December 2011, 21:15   #3  |  Link
vampiredom
Registered User
 
Join Date: Aug 2008
Posts: 233
Quote:
Functions always produce a new value and never modify an existing one.
Yes, as I thought. My reason for asking is fairly obscure, so I won't bother with it more. Thanks.
vampiredom is offline   Reply With Quote
Old 1st January 2012, 20:42   #4  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
I promised you workaround...
You might find inspiration here which is what I recently used:

Code:
global crlf="     "+Chr(10)+ Chr(13)

function SelectMultiple(string c, int n, int i){
str0=c+"_"+string(n)+"_"+string(i)+"="+c+".SelectEvery("+string(n)+","+string(i)+")"+".Subtitle(string("+string(i)+"))"+crlf
str= (i==0) ? str0 : SelectMultiple(c, n, i-1)+str0
return str
}

d1=FFVideoSource(srcfile1, pp="hb/vb:10:60", threads=1)

Eval(SelectMultiple("d1", 5, 4))
Interleave(d1_5_0,d1_5_1,d1_5_2,d1_5_3,d1_5_4)
Result of this function is n clips based on parameter n.
redfordxx is offline   Reply With Quote
Reply

Tags
reference, variable

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 01:53.


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