JS {{ }} evaluation in visible properties

My use case is here to show and hide knobs, depending on fx selection.
First attempt was (because i read it here somewhere) depending on the fx selection, to set an variable with array values(script property), that worked so far.
But because i need this information in the custom module too, i made a dummy switch with key value pairs storing this information per fx(get that per loadjson).

In one knob i made JS Code in the script property "console.logging" the desired 0 or 1 value (to show or hide it). The idea is now to use this code in the visible property to show or hide the knobs.

The code that works in the script property:

var actVal = '@{stomp@{xxx.variables.yy}Sel}';
var indexSel = parseInt(('@{this.id}').substr(('@{this.id'}.lastIndexOf("_") + 1)); // get the number of the knob
var retVal = @{datastore.values}[actval][indexSel];
return retVal;

this could be a oneliner too i guess, but how to transfer this to the visible property?

Thanks!

In a script property you should always avoid using the @{} syntax and use getProp() or get() instead. It's the use of this syntax that lead to your issue; you had to enquote the @{} blocks to make them work in the script, but in a JS{{}} block you must not enquote the @{} blocks.

From Scripting - Open Stage Control (script property)

@{} , OSC{} , JS{{}} and #{} blocks are replaced with their literal value before the script's compilation, therefore it is recommended to avoid these syntaxes and use getProp() and get() instead.

From Advanced syntaxes - Open Stage Control (JS{{}} syntax)

In this context, @{} / OSC{} are seen as variables. When they change, the whole block will be evaluated again.

1 Like

Thanks, i think you mentioned that several times before.
Unfortunatly i can't get it working, so i just tried to make a

JS {{ return 0; }}

to hide the knob, but that doesn't hide it...?

my actual code (console.log does not print out anything):

var actVal = @{stomp@{xxx.variables.yy}Sel};
var indexSel = parseInt((@{this.id}).substr((@{this.id}.lastIndexOf("_") + 1)); // get the number of the knob
var retVal = @{datastore.values}[@{stomp@{xxx.variables.yy}Sel}][indexSel];
console.log(' retVal ' + retVal);
return retVal;

Could that be an error somewhere else ?

JS {{ return 0; }}

There should be no space between JS and {{, maybe that’s the problem ? Clicking on the property name in the inspector to display the computed value usually helps, as well as checking the console (ctrl + k) for parsing errors.

Arghhh, it was the space!
(noticed that the knob was not greyed out, but correctly hidden)

what is here the best option to “store” this JS block ?

with scripts i use a dummyscript to get this easily by @{dummyscript.script}
could i do this also with a js block? (the script would not work as desired , but when getting it via e.g. @{dummy2.script} … ???) What is here “best practice”

Thanks!

You can’t duplicate JS{{}} blocks as you did with that script. Either rewrite the code or use clones with variables overrides.

The rules of get() and getpProp() is only valid in the Script and not in the Props that’s right ?
EDIT : Yes as the title of the link you shared says.