- AVS Presets
- some questions about 'if'
Archive: some questions about 'if'
Serenyddion
14th May 2002 23:15 UTC
some questions about 'if'
I've been working on a preset recently and i've wanted to use if statements such as:
ws=getspec(0,1,0); if(ws>3){ws=3;}
but of couse this syntax and form isn't supported by AVS. So really, my question is: is it possible to do something if a number is greater then a differnt number in AVS? The if statement that they have so far i've only been able to get to work for 0 or non-0... like it says it does..:(
oh and if your interested here's the preset i want to add it to, it's kinda cool in my opnion.
(edit)
ooo i think i figured it out!
d=i*0.98*max(min(getspec(0,1,0),.2),.05)*5;
vwahahaha I'm so smart :p
:) :)
no thanks to all you suckers! (just kidding :p {but what gives i mean you had almost an hour to respond! :p})
dirkdeftly
15th May 2002 21:53 UTC
Just look it up in expression help. It's really not that hard. The structure is if(condition,true,false), and > is replaced by the 'above' function (x>y::above(x,y)) so:
v1=getspec(0,1,0); ws=if(above(v1,3),3,v1);
Serenyddion
15th May 2002 22:05 UTC
Thanks, i didn't see how the above worked into it all.
Anyways it would be nice in nullsoft would implement the 'standard' kind of if statement... I'm sure more people are used to working with that form...
UnConeD
15th May 2002 23:06 UTC
The AVS-language doesn't have any form of flow control, so the if-pseudofunction is only a simple 'hack'. Works nicely though once you get used to it.
And of course, flow-control and all the other whistles and bells is already on the wishlist.
cmountford
16th May 2002 00:24 UTC
it takes time
Serenyddion: I know you said you were kidding when you said, "no thanks to all you suckers! (just kidding {but what gives i mean you had almost an hour to respond! })"
And the people in the forums are generally very friendly. I (as you may have noticed) was signed in at the time you made your post. I immediately looked at it-and I would have gladly written a reply responding to your question-but I didn't *know* the answer for sure.
The Winamp AVS forum is meant to be more like a bunch of helpful (but sometimes busy) people who enjoy answering other people's questions in their spare time. But keep in mind that the forums aren't like a 24-hour technical support line - because what makes the forums so great is that the the everything the members do is on their own free time; so whenever the members are booked up either because of school, a job, or whatever, it may seem to take a long time before your question gets answered.
And considering that many members like me might not know the answer, I'd say getting an answer within a day is a very quick response.
Take for example, my post called "Sneak peek at AVS pack!!!!" Here's a hyperlink-but I'm not sure it will work...
http://forums.winamp.com/showthread....threadid=87661
There's a lot of presets in my preview to my AVS pack, so I anticipate that it will take a while before I get a reply back-because there's so many presets to look through & analyze completely.
But since you were just kidding, I was just answering your question 'what gives' that you didn't get an immediate reply.
So I guess it's all in good fun :)
--C. Mountford--
dirkdeftly
16th May 2002 03:04 UTC
The c++ statements:
if(x)
{
y
}
else
{
z
}
translate into the AVS language as:
if(x,y,z)
The normal > and < operators are equivalent to the above and below functions, respectively. So a>b = above(a,b); and a<b = below(a,b)
Serenyddion
16th May 2002 03:23 UTC
cmountford:
I just said that because i figured that an hour WAS a far too short time for a post to get any responces, which seems to hold true here, and does for most of the other forums i visit...
so the what gives was a joke as well
UnConeD
16th May 2002 10:59 UTC
By the way Atero, you got a detail wrong:
In the C++ code
if (x) { y } else { z }
y and z can be multiple statements, in AVS, they have to return a value.
So in fact, AVS's a=if(x,y,z) is exactly the same as using the ternary operator a = (x ? y : z). Though most people don't even know it exists.