if.. then… else..

Jan 3, 2007 at 11:50pm

if.. then… else..

hello. my first entry:

i have a number that counts itself up with every bang it receives. and then..
i want to build something like that:

if x>320 then
x:=0
else
nothing happens to x. so x:=x…

therefor i’d like to build an object (or a patcher) with one inlet where the number will be checked, and then one outlet where the current number is given out again (which is either 0 or a number between 0 or 320).

can someone help me? would be awesome. i tried much, but i cant see the solution. maybee there is an object i dont know?
thanks a lot, for any help

#29490
Jan 3, 2007 at 11:55pm

try the [if] object, included in the standard distro.

jl

#92292
Jan 3, 2007 at 11:59pm

run it through [% 320]

#92293
Jan 4, 2007 at 12:10am

Welcome. I think you don’t need help here. You almost wrote the
solution ;-)

> i have a number that counts itself up with every bang it receives.
> and then..

Use [counter]
>
> if x>320 then

the [> 320] object should be fine

> x:=0
> else
> nothing happens to x. so x:=x…

then a combination of [sel] an [gate] should work. A quick look at
the help files will give you all you need for this.

But of course, you can go directly to the [if] object’s help file for
a quicker way… ;-)

hope it helps.

Best,
Julien.

#92294
Jan 4, 2007 at 1:06am

Here are three ways to do this…

b

max v2;
#N vpatcher 10 59 610 459;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 200 197 52 196617 t i i i;
#P newex 221 263 47 196617 == 0;
#P newex 221 242 47 196617 ||;
#P newex 200 284 31 196617 *;
#P newex 258 220 41 196617 > 320;
#P newex 221 220 31 196617 < 0;
#P number 200 305 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 200 178 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 265 112 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 265 74 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 265 92 218 196617 if ($i1 >= 0) && ($i1 < = 320) then $i1 else 0;
#P number 63 195 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 117 155 29 196617 t 0;
#P number 63 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 63 135 64 196617 split 0 320;
#P connect 1 0 0 0;
#P fasten 2 0 3 0 122 183 68 183;
#P connect 0 0 3 0;
#P connect 0 1 2 0;
#P connect 7 0 14 0;
#P connect 14 0 11 0;
#P connect 11 0 8 0;
#P connect 14 1 9 0;
#P connect 9 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 11 1;
#P fasten 14 2 10 0 247 217 263 217;
#P connect 10 0 12 1;
#P connect 5 0 4 0;
#P connect 4 0 6 0;
#P pop;


barry threw
composition : sound : programming
http://www.barrythrew.com
bthrew(at)gmail(dot)com
857-544-3967

(if you would see the stars clearly,
look hard at the surrounding darkness)
-Ooka Makoto

#92295
Jan 4, 2007 at 1:25am

thanks a lot to all of you.
you helped me a lot. love

#92296

You must be logged in to reply to this topic.