03-31-2004, 07:12 AM
|
Free Member
|
|
Join Date: Mar 2003
Location: Palma de Mallorca - España
Posts: 2,925
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How can I execute conditional user defined functions like:
c = (x==y) ? userdefined1() : userdefined2()
where userdefined1 and userdefined2 results, are clips of not equal resolution.
|
Someday, 12:01 PM
|
|
Site Staff / Ad Manager
|
|
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
|
|
|
03-31-2004, 07:22 AM
|
Free Member
|
|
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The direct way :
Code:
u1=userdefined1()
u2=userdefined2()
c = (x==y) ? u1 : u2
The smart (and more efficient) way
Code:
u = (x==y) ? "userdefined1()" : "userdefined2()"
c = Eval(u)
Never used the second one but should work.
|
03-31-2004, 11:11 AM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Maybe what you want is something like this
x==y ? c=userdefined1() : c=userdefined2()
-kwag
|
03-31-2004, 12:22 PM
|
Free Member
|
|
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
And if the "then" way will "do nothing" I remember still this was
x==y ? c=userdefined1() : NOP
|
03-31-2004, 12:35 PM
|
Free Member
|
|
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Let's go for an other wzy to do all that :
Code:
(x==y) ? userdefined1() : userdefined2()
c=last
Do you need more ?
|
03-31-2004, 12:57 PM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Dialhot
Let's go for an other wzy to do all that :
Code:
(x==y) ? userdefined1() : userdefined2()
c=last
Do you need more ?
|
Why that one
Either userdefined1() or userdefined2() will ALWAYS evaluate, so "c" will always have the value of the true or false condition.
So c=last is redundant, because it's already assigned once in either userdefined1() or in userdefined2()
But then, we can get really obfuscated here, don't we
-kwag
|
03-31-2004, 02:44 PM
|
Free Member
|
|
Join Date: Mar 2003
Location: Palma de Mallorca - España
Posts: 2,925
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
As I can see
Quote:
Originally Posted by Prodater64
How can I execute conditional user defined functions like:
c = (x==y) ? userdefined1() : userdefined2()
where userdefined1 and userdefined2 results, are clips of not equal resolution.
|
and
Quote:
Originally Posted by Dialhot
Code:
u1=userdefined1()
u2=userdefined2()
c = (x==y) ? u1 : u2
|
and
Quote:
Originally Posted by kwag
Maybe what you want is something like this
x==y ? c=userdefined1() : c=userdefined2()
-kwag
|
are the same.
In Dialhot example, he asign the userdefined functions 1 an 2 to two variables and later (translation) wright the conditional statement same like mine one.
In Kwag example, he define his condition and later asign the results at c.
It is like say "If x = y, then c=udf1, if not c=udf2", and my way, "c=udf1 if x = y,c=udf2 if not". But what is the correct way? or all are the right ones?
|
03-31-2004, 03:15 PM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Prodater64
Quote:
Originally Posted by Dialhot
Code:
u1=userdefined1()
u2=userdefined2()
c = (x==y) ? u1 : u2
|
and
Quote:
Originally Posted by kwag
Maybe what you want is something like this
x==y ? c=userdefined1() : c=userdefined2()
-kwag
|
are the same.
?
|
Nope. Not the same at all.
The statement:
c = (x==y) ? u1 : u2 assigns true or false ( 1 or 0 ) to c, depending on the value of x and y.
The statement:
x==y ? c=userdefined1() : c=userdefined2() assigns the correct value, depending on the condition that evaluates to true or false.
-kwag
|
03-31-2004, 03:39 PM
|
Free Member
|
|
Join Date: Mar 2003
Location: Palma de Mallorca - España
Posts: 2,925
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ohh!, I understand, thank you, Kwag.
And thanks to all.
Another question:
When I use the NOP statement, the script will continue beyond the conditional evaluation:
For example:
x==y ? c=userdefined1() : NOP
bicubicresize()...
In this case, resize will be applied whatever would be the condition?
(I hope you understand my english!!!)
|
03-31-2004, 03:48 PM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Prodater64
Ohh!, I understand, thank you, Kwag.
And thanks to all.
|
Just in case:
== (comparison) is not the same as = (assignment)
-kwag
|
03-31-2004, 03:52 PM
|
Free Member
|
|
Join Date: Mar 2003
Location: Palma de Mallorca - España
Posts: 2,925
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry, I had edit my previous post and you don't saw the last question.
|
03-31-2004, 04:21 PM
|
Free Member
|
|
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by kwag
c = (x==y) ? u1 : u2 assigns true or false ( 1 or 0 ) to c, depending on the value of x and y.
|
Nope !
Actually this statement set c to u1 is the condition is true, u2 if not. And actually u1 is equal to the result of userdefined1 and u2 the result of userdefined2.
So that is EXACTLY what wee need to have.
Quote:
The statement:
x==y ? c=userdefined1() : c=userdefined2() assigns the correct value, depending on the condition that evaluates to true or false.
|
The only advantage of this uppon the previous is that you evaluate userdefine1 OR userdefine2, and not both ones.
So it's more efficient (as I told in my first post !)
but it will work only if avisynth grammar accepts non constant lvalues with ":" operator
Avisynth is not C language.
|
03-31-2004, 11:38 PM
|
Free Member
|
|
Join Date: Feb 2003
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
removed stupid question
|
All times are GMT -5. The time now is 01:40 AM — vBulletin © Jelsoft Enterprises Ltd
|