Mathieu Bouchard wrote:
- if you create a patch using your [range] abstraction, then
connections from the outlets are cut next time you load the patch. this because you cannot create outlets dynamically early enough without something like an [initbang], that is executed even before [loadbang]
Actually, I just found a hack. Edit your .pd file with a text editor in this way:
replace "loadbang;" by "r $0-initbang;"
add a line at the very end that says just "$0-initbang bang;", no backslash, no "#X obj", no object position.
This works in all versions of Pd. If you don't understand how this works, it's normal. Furthermore, to edit this patch, -noloadbang does not work anymore, so you have to undo step 2 before any edit in pd, and redo it after any edit in pd.
hey that is a hack! ;-) (a nice one!)
but has also an additional drawback: you have to add '$0-initbang bang;' each time you edit the patch in pd, cause pd discards everything it doesn't know about. this is a nice point for a feature request of an internal [initbang].
indeed, you are right... dynamic patching in Pd is still troublesome.
anyway it doesn't mean that things are impossible... they just require you much thinking.
my example (of range.pd) was just a proof of concept.
and also, it's true: if you know how to code externals (example: C, or even Tcl (tclpd) or Python (pyext)) you probably do the same thing by programming rather than by patching it, especially if it's not properly straightforward.
Best regards, Federico Ferri