I have written a small script to automatically name a subpatcher/bpatcher/abstraction. If I give an argument ton my JS object containing this script, it sets the varname of the patcher its contained in. That's pretty easy, you can find a lot of example for that on Cycling's Forum.
I also added some easy but neat features like : if you bang it, it outputs the current varname. If you send it the message "parent" and the subpatcher/bpatcher/abstraction is actually loaded in something that has a script name, then it returns that name.
Of course, if I don't give any argument to the JS object, it does nothing when loaded. But you can set the name afterwards with a "set" message.
Anyway, this is rather handy.
The problem is this one :
Imagine you have a bpatcher (for example) with this JS script inside whith an argument, it will auto-name the bpatcher every time it's loaded. Now, if the user (I mean the person who added the bpatcher) wants to change the name "by hand" he/she can do it in the inspector of the bpatcher. However, this "manual" change won't actually stay, even if the person saves the patch. Why ? Because next time it's loaded, my script is going to rename the bpatcher with the argument it has.
I would like to avoid that, meaning, if the person decide to change the scripting name, then it overrides the auto-naming. And of course, I would like that to be automatic (ie. without needed to open the patch where the JS is).
Is it clear ?
I have no idea how to do that.
The first thing is to detect that a "manual" naming occurred. Is that possible with JS ?
Second, the JS has to permanently stop renaming once it detected that. It could be simply by destroying itself (is that possible ?). Or inhibit the auto-name in a way ? Or change it own argument ?
I though you, Maxers (and JS nerds, at least for some of you) might have some idea about this...