Script : send osc message with address based on value

I would need to send an osc message within a script, with address based on the value of the widget’s current value.

The widget is for ex a switch with values :

{
"Value 1": "foo",
"Value 2": "bar"
}

Expected result :
when I click on « Value 1 » : I’d like it to send a message :
/foo/init bar

If I use the address prop with /@{this}/init
It works just fine.

But I need to do it inside a script.

When my script prop is
send('/@{this}/init', value)
or
send('/@{this.value}/init', value)

it returns :
(DEBUG, OSC) Out: { address: ‘/undefined/init’, args: [ { type: ‘s’, value: ‘bar’ } ] } To: 127.0.0.1:8000

Undefined ?

If I use any other widget’s prop instead of value, it works fine. For ex :
send('/@{this.left}/init', value)
it sends :
(DEBUG, OSC) Out: { address: ‘/10/init’, args: [ { type: ‘s’, value: ‘bar’ } ] } To: 127.0.0.1:8000

So why doesn’t it work with value ?

I also tried :

if (value !== undefined) {
send('/@{this.value}/init', value)
}

…same result

What’s wrong here ?

help please !

Don’t use @{} in scripts, use get() instead.

send('/' + get('this') + '/init', value)

so simple, thanks !
but… out of curiosity, why does it work with

send('/@{this.left}/init', value)

?

Here is the reason : https://openstagecontrol.ammd.net/docs/widgets/advanced-syntaxes/#circular-references-cases
(script is not a dynamic property)

of course !
sorry for the dumb question :flushed:

thanks again

No problem, there’s no dumb question :slight_smile: (btw there no particular reason for script to be non-dynamic besides the fact that I didn’t implement the update routine)

This got me again! I wonder if you might be able to put this in a rather bold font in the help popup!

image