VAR with Object as value

I have a beginner Syntax Issue I can't seem to solve.

I have a variable on a switch which is meant to have this value:
{Legato:1, 'Kurze Artikulation': 2, 'Lange Artikulation': 3, Runs: 4}

These were my ideas of how to assign it while loading the patch:
Values Prop

VAR{Articulations, #{
{Legato: 1, KurzeArtikulation: 2, LangeArtikulation: 3, Runs: 4}
}
}
#{
VAR{Articulations, #{
{Legato: 1, KurzeArtikulation: 2, LangeArtikulation: 3, Runs: 4}
}
}
}

both of them don't work though.

onCreate Prop
(after putting VAR{Articulations, 1} in the values Prop)

var list1 = {Legato:1, 'Kurze Artikulation': 2, 'Lange Artikulation': 3, Runs: 4}

setVar("this", "Articulations", list1)

This one works kind of but not while loading the json but only when I click inside the onCreate and sort of reload the code again.

May I ask for your help? :slight_smile:

The last thing you tried was actually a good idea, but in this case it doesn't work because values is not a dynamic property, it requires the widget to be recreated when modified and this cannot happen during the creation phase. This would work though

setTimeout(()=>{
  setVar("this", "Articulations",  {Legato:1, 'Kurze Artikulation': 2, 'Lange Artikulation': 3, Runs: 4})
}) // introduce a tiny delay to get out of the widget phase

The correct syntax for your first attempt is

#{VAR{Articulations} || {Legato: 1, KurzeArtikulation: 2, LangeArtikulation: 3, Runs: 4}}
1 Like

Ah thank you very much! :slight_smile: