PDA

View Full Version : conditionals like "if" "elseif" and "else"


FreQi
6th November 2003, 07:16
It's there some kind of conditional functions of AVISynth other than the var = (condition) ? when true : when false syntax? I just want to do something like
if (var == value)
{ a = clip.something()
b = clip.somethingelse()
c = clip.another()
}
elseif (var == eulav)
{ a = clip.this()
b = clip.that()
c = clip.other()
}
else
{ a = clip.blah()
b = clip.whee()
c = clip.blech()
}

I've been looking over the avisynth.org manual and this forum but don't see anything of that nature...

Didée
6th November 2003, 09:36
FreQi,

no, that functionality doesn't exist explicitly - but it's no big deal.
With your example, two "problems" arise:
1. no elseif
2. no chance to do more than one operation per "if"-case :(

1. can be solved by nesting the conditional statements
2. can be solved by defining functions for that

So, your example could e.g. look like that:

function MyIfCase(clip)
{ global a = clip.something()
global b = clip.somethingelse()
global c = clip.another()
}
function MyElseifCase(clip)
{ global a = clip.this()
global b = clip.that()
global c = clip.other()
}
function MyElseCase(clip)
{ global a = clip.blah()
global b = clip.whee()
global c = clip.blech()
}

#---------------------------------

var == value ? MyIfCase(clip)
\ : ( var == eulav ? MyElseifCase(clip)
\ : MyElseCase(clip)
\ )Didn't even test it, but I suppose it will work. ;)


- Didée

mf
6th November 2003, 14:18
These "conditional queues" give some pretty nasty effects though.
See here (http://forum.doom9.org/showthread.php?s=&threadid=52066&perpage=40&pagenumber=2) for more details.

FreQi
7th November 2003, 09:34
Not even a case or a switch conditional eh?

I've tried a few things so far and I've got the function working, but it really seems to have slowed the whole thing down. I'll post my function once I have it functional. Perhaps you could suggest how to better it then.

stickboy
7th November 2003, 10:30
There's the Select function, and there's also my quick-and-dirty SelectByString (http://www.avisynth.org/~stickboy/SelectByString.zip) AviSynth C plug-in.

FreQi
7th November 2003, 10:52
I just posted the function (http://forum.doom9.org/showthread.php?threadid=64621) that I was about this for (the "Fixing ABC's Credits" post) if you care to take a peak, I'd like your suggestions on any improvements.

Any btw, I was wrong about things slowing down. Turns out the repeat rate on my keyboard was borked ;]