How to send variable # arguments to an abstraction
Can anyone tell me how to do this? I’ve created some abstractions, and at the moment I have to copy the abstractions and enter the # argument into the object box. Is there a way I can trigger the box to contain a different number?
simply add inlets for each of the [i #1] in
the abstraction, then you can work with them
exactly like you re used from objects.
I’ve created an inlet within the abstraction, but what do i connect it to within the object, and what do i put in the message box (for example "set #1 7" or something?). I assume i can just send it a number.
I may be sounding stupid but can’t work it out! hehe
it is a bit difficult, but only when you do it
the first time.
i forgot to tell you something important:
you have to connect a loadbang to every [i #1]
to make the whole thing work.
here is an example abstraction.
#N vpatcher 96 821 516 1081;
#P number 63 134 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 128 68 50 196617 loadbang;
#P inlet 63 51 15 0;
#P outlet 63 171 15 0;
#P newex 63 96 50 196617 i $1;
#P comment 135 138 142 196617 purpose of this abstraction: output its first argument;
#P connect 3 0 1 0;
#P connect 4 0 1 0;
#P connect 1 0 5 0;
#P connect 5 0 2 0;
save that as [tobysucks], and call it up from another
patcher window as [p tobysucks].
then set an argument "303"; [p tobysucks 303].
then change the argument to "404".
then try 505, 606 and so on.
when you have tried 253402534 your wife will call
you to do the dishes.
you will see that this works only because of the loadbang,
which bangs again as soon as you set or change one argument.
the inlet is connected to the [i] so that you can also
just send data into the abstaction, this process has
nothign to do with the fact that the [i] can also be set
by an argument.
just for the records, it works of course the same way
with [f] or [s] arguments.
argh, now i told you bullshit again.
of course do NOT make a [p] – it only works when
the subpatch is loaded as abstraction! ;)
Ah, I see.
mmm… How do you change the i (#) number though, without having to type 303 or whatever into the object/abstraction?
By that I don’t mean the number output by the i number, I mean the actual variable number (say changing from i 303 to i 304). Rahrahrah
Can anyone help with this problem? Would be much appreciated! (Thanks for the response Roman)
I basically need to vary the argument of an abstraction, without having to enter the number into the object box: Therefore changing the value of "#" by sending the abstraction a number.
Thanks for any replies!
It’s most likely going to involve scripting. Check out the thispatcher
object and the scripting tutorial. Sprintf using the %c feature to
create the # sign. (look up # using key)
pak numberFor#Character TheNumberOfTheOutlet (e.g. 66 3)
sprintf whateverTheCommandsToMakeTheObject %c%d
I use a sprintf created by scripting to create my abstractions which
convert multislider lists into matrix~ coordinates. (it’s generated at
instantiation, but it shouldn’t be that different) I’ve posted them
before to the list, but if you want them, e-mail me and I’ll send them
> I basically need to vary the argument of an abstraction, without
> having to enter the number into the object box: Therefore changing
> the value of "#" by sending the abstraction a number.
You haven’t described any reason that simply using an inlet would not
work for you. Add an inlet to the abstraction, massage the input as
necessary, and connect it to where it needs to go. I’ve found very few
instances where I need to change an object’s properties and can’t
accomplish it through a message of some sort sent via a patchline.
In those cases – which generally involve reinstantiating an object
anyway, eg for a different number of in/outlets – I use scripting or
Maybe this is a case for #0 and maybe not. I made a goofy little
abstraction once to tell me the instantiation number given by a
#0-argument. This is one way abstractions can report their id numbers
back to their context. I refer to it as guid but you can call it
whatever you want. Use this way:
[guid #0-id] < -- use *exactly* this way, no changes
I’m sure there are better ways. After I came up with this, my project
eventually stopped using it due to improved design. Something to think
about. Here’s the abstraction (copy/pasted):
#N comlet returns guid of parent , where argument is #0-id;
#P outlet 97 179 15 0;
#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P newex 60 60 61 9109514 select bang;
#N comlet bang to return guid portion of #0-id argument;
#P inlet 60 36 15 0;
#P newex 60 112 228 9109514 prepend $1;
#P newex 60 137 84 9109514 regexp ([\\d]+)-id;
#P message 60 89 36 9109514 ignore;
#P connect 1 1 5 0;
#P connect 2 0 1 0;
#P connect 0 0 2 0;
#P connect 4 0 0 0;
#P connect 3 0 4 0;
#P window clipboard copycount 6;
> I basically need to vary the argument of an abstraction, >without having to enter the number into the object box: >Therefore changing the value of "#" by sending the abstraction >a number.
that is not possible and i do not see what it could be
typing arguments into boxes is a job you do to set
arguments, and not to display the current argument.
but it should be no problem just to use numboxes to enter
arguments and place the numboxes onto the object box.
Forums > MaxMSP