more than one parameter in a jsui/v8ui ?

klaus filip's icon

is it possible to hold more than one parameter in a jsui/v8ui ?

..tweaking with
notifyclients()
getvalueof()
setvalueof()

or is it strictly fixed to the one and only varname?

TFL's icon

It depends on what you want to do. The strict answer is, as far as I know, "only one value", but that one value could be a list or a dictionary containing more data.

But depending on what you want to do, you could use attributes, custom methods with a Maxobj.message()or messnamed().

Here's an example with attributes, using pattr to get/set both attributes:

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

klaus filip's icon

thx TFL !

thats very interesting, especially the getter functions were not on my screen..
here is the enhancement with these attributes/parameters inside pattrstorage...

now this leads to the Q if we can dynamically script javascript ?
the eval() function might do, but creating a 'declareattribute' in the main code is not within its concept.
any option to paste javascript-code together from modules?
filling the codebox?

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

TFL's icon

A few days ago I learnt that let made attributes handling a bit tricky, hence the need to declare custom getters and setters. Using var is much more convenient as you can rely on the default getters and setters:

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

I doubt dynamically creating attributes is a good idea, and I'm pretty sure we could come up with a better idea. Why do you want to do this?

Is it to store some arbitrary number of values inside of a pattrized js object? If so, you could use getvalueof() and setvalueof() to handle an array or dict value that you can structure however you want.

Here is a simple example with an array:

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

klaus filip's icon

my approach is a v8ui, that should control list-parameters of a patch.
the most straight forward method would be ParameterListener, but currently this is not working in v8.

anyway here is a followup patch that grabs pattrs as v8-attributes.

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