#N canvas 166 111 516 471 10;
#X text 9 34 WHAT IS THIS ALL ABOUT?;
#X text 21 60 Depending on the complexity of your patches \, you may
need to control whether or not messages will be used by only ONE patch
\, or throughout all open patches. The scope of a message is considered
either 'local' or 'global'.;
#N canvas 146 223 606 389 GLOBAL_SCOPE 0;
#N canvas 0 22 254 169 example_a 0;
#X obj 18 9 r foo;
#X floatatom 18 34 5 0 0 0 - - -;
#X obj 24 96 r a-foo;
#X floatatom 24 116 5 0 0 0 - - -;
#X connect 0 0 1 0;
#X connect 2 0 3 0;
#X restore 34 56 pd example_a;
#N canvas 2 238 256 163 example_b 0;
#X obj 12 9 r foo;
#X floatatom 12 28 5 0 0 0 - - -;
#X obj 15 74 r b-foo;
#X floatatom 15 93 5 0 0 0 - - -;
#X connect 0 0 1 0;
#X connect 2 0 3 0;
#X restore 155 57 pd example_b;
#N canvas 0 473 231 169 example_c 0;
#X obj 12 8 r foo;
#X floatatom 12 30 5 0 0 0 - - -;
#X obj 12 65 r c-foo;
#X floatatom 12 86 5 0 0 0 - - -;
#X connect 0 0 1 0;
#X connect 2 0 3 0;
#X restore 269 57 pd example_c;
#X text 377 58 Open these subpatches.;
#X obj 43 142 s foo;
#X floatatom 43 126 5 0 0 0 - - -;
#X text 33 85 Click-n-drag these number boxes and notice the appropriate
receive objects in each open sub-patch.;
#X floatatom 102 126 5 0 0 0 - - -;
#X floatatom 179 126 5 0 0 0 - - -;
#X floatatom 252 126 5 0 0 0 - - -;
#X obj 102 142 s a-foo;
#X obj 179 142 s b-foo;
#X obj 252 142 s c-foo;
#X text 18 23 GLOBAL SCOPE - send and receive messages in ALL OPEN
PATCHES;
#X text 35 177 Send objects simply post their information to the cyberspace
within your computer (that's one way to look at it!) Receive objects
simply keep their ears open for all messages floating through that
cyberspace from send objects of the same name! Hence \, if you name
a [send] something like "foo" \, then all [receive] objects in open
patches named "foo" will 'hear' those messages. Also note that the
term 'open patches' includes all sub-patches \, abstractions and patches
that are currently open in Pd - they don't have to be VISIBLE...they
only have to be active.;
#X connect 5 0 4 0;
#X connect 7 0 10 0;
#X connect 8 0 11 0;
#X connect 9 0 12 0;
#X restore 11 157 pd GLOBAL_SCOPE;
#N canvas 146 22 618 662 LOCAL_SCOPE 0;
#X text 4 9 LOCAL SCOPE -send and receive messages within a SINGLE
PATCH;
#X text 13 37 There are many cases where you may want messages to be
sent within a single patch. For example \, you might have designed
many modules with a receive object called [r number] but you want that
'number' to be passed to only the objects within a single module so
that they don't effect the performance of the other modules.;
#X obj 84 222 r \$1;
#X obj 18 245 s \$1;
#X floatatom 18 221 5 0 0 0 - - -;
#X floatatom 84 248 5 0 0 0 - - -;
#X floatatom 189 224 5 0 0 0 - - -;
#X floatatom 278 250 5 0 0 0 - - -;
#X obj 278 224 r \$1-foo;
#X obj 189 248 s \$1-foo;
#X floatatom 367 224 5 0 0 0 - - -;
#X floatatom 456 250 5 0 0 0 - - -;
#X text 62 513 LOCAL_SCOPE (and inheritance);
#X obj 456 224 r \$2-dave;
#X obj 367 248 s \$2-dave;
#X text 14 541 The words "and" and "inheritance" are arguments that
I used when I created the abstraction called "all_about_scope_and_locality".
These two agruments are now available in this patch by using \$1 or
\$2 variables. There's more information about this in the section called
'Inheritance'.;
#X text 13 267 In the examples above I have used a variable ($1) to
name these [send] and [receive] objects. The value of this variable
is assigned either by Pd (randomly for each abstraction or patch) \,
or by me with the use of arguments.;
#X text 11 335 If you would like Pd to assign the value of your local
variable at random \, use \$0. This will ensure that your local variables
will always be 'local' and won't ever correspond with variables in
other open patches or abstractions.;
#X text 12 138 In these cases \, you should use "local variables" ...as
in [r \$0-number] to name your send and receive objects. Local variables
are assigned using dollar signs and numbers. There is more documentation
about this in 2.control.examples/locality.pd;
#X text 13 424 If you want to define the value of the local variables
\, you can use 'arguments' when you create the abstraction and then
refer to those arguments by using \$1 (for the first agrument) or \$2
(for the second) and so on. Notice in the 'title' of this patch \,
you should see:;
#X connect 2 0 5 0;
#X connect 4 0 3 0;
#X connect 6 0 9 0;
#X connect 8 0 7 0;
#X connect 10 0 14 0;
#X connect 13 0 11 0;
#X restore 11 186 pd LOCAL_SCOPE;
#N canvas 145 31 610 615 INHERITANCE 0;
#X text 20 18 The word "Inherit" means to "receive a characteristic
from one's parent".;
#X text 19 59 In Pd \, all abstracions and subpatches have 'parents'
-- the parent is the main patch which created the instance of the abstraction
or subpatch.;
#X text 18 117 We can use 'arguments' when creating an abstraction
in a patch to send values to those 'children'. For example \, this
help document contains a number of different subpatches and abstractions.
One abstraction is called "all_about_scope_and_locality" -- you are
currently reading a subpatch in that abstraction. When I created that
abstraction in the parent patch \, I defined two arguments: "and" and
"inheritance". So \, those two values are now available throughout
this abstraction and all of its subpatches!;
#X obj 49 327 symbol \$1;
#X symbolatom 49 356 0 0 0 0 - - -;
#X obj 49 305 bng 15 250 50 0 empty empty click_here_to_see 0 -6 0
8 -262144 -1 -1;
#X symbolatom 146 356 0 0 0 0 - - -;
#X obj 146 327 symbol \$2;
#X text 24 388 So \, if a [send] object is named "$1-foo" or "$2-foo"
inside this abstraction \, Pd identifies that [send] object as "and-foo"
or "inheritance-foo".;
#X obj 47 466 s and-foo;
#X obj 47 516 s \$1-foo;
#X obj 47 445 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 47 493 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 163 495 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 163 462 r and-foo;
#X obj 280 443 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 280 491 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 431 497 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 280 464 s inheritance-foo;
#X obj 431 464 r inheritance-foo;
#X obj 280 514 s \$2-foo;
#X connect 3 0 4 0;
#X connect 5 0 3 0;
#X connect 5 0 7 0;
#X connect 7 0 6 0;
#X connect 11 0 9 0;
#X connect 12 0 10 0;
#X connect 14 0 13 0;
#X connect 15 0 18 0;
#X connect 16 0 20 0;
#X connect 19 0 17 0;
#X restore 11 217 pd INHERITANCE;
#X text 16 285 From section 2.6.5 of the Pd manual \, Miller Puckette
says:;
#X text 39 316 "Note that the expansion of variables such as \$0 and
\$1 only works at the beginning of the symbol. So \, for instance \,
[rats-$1] will not be expanded. Occasionally you may want to have double
or triple sustitutions. This can be done one stage at a time by nesting
abstractions (with each subpatch adding its own $-variable to the begining
of a symbol and passing that on as agrument to a further abstraction."
;
#X text 7 261 MILLER'S WISDOM;
#X obj 4 4 cnv 15 500 20 empty empty all_about_scope_and_locality 20
10 1 18 -233017 -66577 0;
#X obj 471 5 pddp/pddplink http://puredata.info/dev/pddp -text pddp;
