Name variables with scripting

ted_greene17@hotmail.com's icon

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,

I have no javascript knowledge but would be willing to learn.

Many thanks, Ed

Included in the attachment is the abstraction 'sliderstereo' and a test patch to attempt to make it work.

Mattijs's icon

Moving this topic from the archives to MaxMSP

Mattijs

Leafcutter John's icon

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?

J.

ted_greene17@hotmail.com's icon

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

Leafcutter John's icon

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:

Max Patch
Copy patch and select New From Clipboard in Max.

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,

J.