Name variables with scripting
Hi, I am trying to make it possible to load an abstraction which once loaded is automatically connected to a hslider.
The problem is that I cannot figure out a way of automatically naming the abstraction as a variable. This means that when thispatcher receives the message connect var1 0 sliderstereo 2, it cannot do this as the abstraction is not yet named, I understand that thisobject is only operational when used in an inspector patch, but cannot figure out another way of naming the abstraction autmoatically,
Many thanks, Ed
Included in the attachment is the abstraction ‘sliderstereo’ and a test patch to attempt to make it work.
Moving this topic from the archives to MaxMSP
I could be confused about what you are trying to achieve but try this:
Take all the scripting & thisobject stuff out of the stereoslider abstraction you don’t need it.
save the abstraction where max can find it (externals folder)
send this message to thispatcher:
‘newex 29 118 65 196617 sliderstereo, objectname frank’
This creates a new ‘sliderstereo’ and names it ‘frank’
is that what you wanted?
That’s exactly what i needed, thanks very much for your help, that has been driving me mad for a while. How can i learn things like that, is there a tutorial concerning scripting that you can recomend? thanks again, Ed
most of the ‘thispatcher’ scripting messages are explained in the Max Reference Manual. But a good tip i picked up on these forums is that you can open a saved max patch as text (from the max’s file menu) and look at the scripting for the creation of each object. Very similar syntax is used to control thispatcher so often the relevant bits can be copied into your patch.
So to work out the solution to your problem i created a ‘sliderstereo’ abstraction and manually named it ‘frank’ i then saved the patch and re-opened it as text.
It looks like this:
#N vpatcher 304 44 904 444;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 28 143 65 196617 sliderstereo;
#P objectname frank;
It’s pretty easy to spot the bit that creates the object, and the following line that names the object. From there it took a experimentation to work out how to combine the two lines into a working message to ‘thispatcher’
best of luck,