aboutsummaryrefslogtreecommitdiff
path: root/doc/pddp/all_about_expr_if.pd
blob: 7984aa5af91ad0183eb646e34282e0c8dba97328 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#N canvas 0 0 448 500 10;
#X obj 1 1 cnv 15 445 20 empty \$0-pddp.cnv.header expr_if 20 10 1
18 -261106 -33289 0;
#X obj 407 2 pddp/pddplink http://puredata.info/dev/pddp -text pddp
;
#X floatatom 23 315 5 0 0 0 - - -;
#X floatatom 23 266 5 0 0 0 - - -;
#X obj 374 374 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
10;
#X floatatom 23 441 5 0 0 0 - - -;
#X floatatom 23 376 5 0 0 0 - - -;
#X obj 83 441 print;
#X floatatom 374 353 5 0 0 0 - - -;
#X obj 23 400 expr if($f2 != 0 \, if($f1 % 13 != 0 \, random($f1 -
$f2 * 0.5 \, $f1 + $f2 * 0.5) \, $f1) \, $f1 % 60);
#X text 20 93 b) an expression to evaluate if the condition is true
\, and;
#X text 20 78 a) the condition \,;
#X text 20 37 The [expr] \, [expr~] \, and [fexpr~] objects allow you
to build a conditional statement using the "expr if" syntax. It is
made up of three parts \, enclosed in parentheses:;
#X text 20 126 Each part is separated by a comma.;
#X text 20 108 c) an expression to evaluate if the condition is false.
;
#X text 20 239 c) if the condition is false \, the number 20 is output.
;
#X text 20 340 You can nest other functions within the if function
\, including the if function itself.;
#X text 20 157 By scrolling the number box below you can see the [expr
if] function in action. When a number is received at the inlet:;
#X text 20 189 a) the condition "$f1 < 20" checks if the input is less
than twenty.;
#X text 20 219 b) if true \, the value is subtracted from twenty and
output.;
#X obj 1 478 cnv 15 445 20 empty \$0-pddp.cnv.footer empty 20 12 0
14 -233017 -33289 0;
#N canvas 44 246 494 344 META 0;
#X text 12 85 LIBRARY PDDP;
#X text 12 45 KEYWORDS;
#X text 12 5 GENRE all_about_pd;
#X text 12 25 NAME expr expr~ fexpr~;
#X text 12 105 HELP_PATCH_AUTHORS Dave Sabine \, May 5 \, 2003 . Jonathan
Wilkes revised the patch to conform to the PDDP template for Pd version
0.42.;
#X text 12 65 DESCRIPTION an explanation of the "if" function from
sly and the expr family stone;
#X restore 392 480 pd META;
#N canvas 9 355 428 136 Related_objects 0;
#X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0
14 -261106 -33289 0;
#X text 7 2 [expr] if- Related Objects;
#X obj 22 42 moses;
#X obj 72 42 select;
#X obj 132 42 spigot;
#X restore 103 480 pd Related_objects;
#X obj 6 480 pddp/pddplink all_about.pd -text All About Pd;
#X obj 23 290 expr if($f1 < 50 \, 50-$f1 \, 50);
#X connect 3 0 24 0;
#X connect 4 0 9 1;
#X connect 6 0 9 0;
#X connect 8 0 4 0;
#X connect 9 0 5 0;
#X connect 9 0 7 0;
#X connect 24 0 2 0;