How to programatically access script attributes?
- 
 I have a script with 3 knobs. knb1, knb2, knb3. I would like to access these controls from another script in order to set their values. I know I can access them by index, but let's say I don't know the index I just know the name. How could I set the correct control to the correct value?Here are somethings I tried that didn't work. script.setAttribute("script." + knb1, 50);
 script.setAttribute(exec("script." + knb1), 50);
 script.setAttribute(script["knb1"], 50);This is a simplified example of my project. The reason I'd like to do it this way is because I want to set the attributes of several scripts within a loop and I may not always want to set all of the scripts attributes, only some of them, so I can't just iterate through all of the indexes I need to use the attribute's name. 
- 
 @d-healey What if you declare them as global? 
 So you could directly access by name:
 script.setAttribute(knb1, 50);HiseSnippet 828.3oc0V0saSCCE1tqFncrIlfGfncUmznJcrMPBMst0ePUisUQFSb2jahaq0RrqRbFTg3MjGBdD3M.NNIsIsKZqqBDhdUO+5uy474bbWeoMKHP5ivktX7HFB+Th0XgZXigTt.0oIBuN4TZfh4aDq53winAALGDFux6zJvkJhh98yCOl5RE1rTUHzkRtM68bOtJUa25mvccaScXWv8x38t06XKEMjtxP.OqPLQin1WSGvNipcq.AgeTKGtR5aonJV.BW7XoyXqgxOKh8+Rd.umKSKTCYAIJVcaoqiFwZsnFC4tNcmT2AHHKcS6BqD2EdA4TtCep9ztwyhLXjFQ19AtvcAuZ2O7LyCdEx.uhwvaChksOejJ0hFaqR5HfAUeJLBxBqXeQEN.SZHAODppdzqYs8AgoQTYeSysM1yzbq2tV40JCCh.kwMTei4NoZFGXDwPpNfoloIUYyXWSaN01LNYymhpAL0QJkOuWnhU4DgrWssMLqtm169gBaEWJLjhyjJ14hJaU9qkKU9akMl2T+94ZSWi9RWWletl0bN+6JvJhPudL+sgp2MjM0Qn4O6zc0Ea5ZG2xy3nTzQvUmOhkHmkdNopmX0DMsXypJsFypMpzxwsTU2ldgRnDv+9XmlTEEXb3DcfeiX9JttZwMY2.Wki4ekHMYAWqjifKyKH474jawNxijh+NYfqrG00HhV.jsITVft0P5MRJ.gJaFYMgd8+Cko7eJJy+PZBtPh6fqpnA95IiVKWtCyGwg44iIQCHTT+H8K7+3PzBG7NyG7RxP03Mg1.yi6EweI8.spOdlS+Ajmcxjm5tykmaekA1pHcBcopYW0n2ulX.naybcQ+caQ.WMN692Gv9GyEd83hB2MHc4J6g4i2B4fWMU5uLdS1luFoU+9LaUJXKRZ+okc08C.JePFp3hAmRgcc.gfbVnmE73FaFfDgf4BGDAWPSshkM0xQTOlvIR3WvuDi0zx3Di0lXD4Qs8kWYGesR+dgmDoAvjH5YSkf2uAxFSuLRHlUMQdvp6qrs0shWBXO+X1YIh4UKQL6tDwr2RDy9KQLudIh4M2YL5WMcTnR5EeMATzsUz20v3VBJvxhXjneCZqfhX
- 
 I never thought of that. For my particular project I don't think it's the best solution because I have a lot of scripts and I don't want to pollute the global namespace with all of the controls, but for a smaller project it's definitely a good option. I think I need a new function, something like getAttributeId(). I'm looking at the HISE source now to see if I can figure out how to add it.
- 
 @d-healey maybe you can just declare an array per script as global for the moment with const var inside... not sure it works though... 
 I also tried with a get("id") like solution but it doesn't work so effectively, having an API for this seems a good solution ;)
- 
 I found a solution! I added a getAttributeIdfunction to HISE :p
- 
 @d-healey oh your a boss my man!    
- 
 Here's a little snippet to quickly make an organised object containing every attribute ID for every script, indexed by the script's ID. //Get MidiProcessors const var processorIds = Synth.getIdList("Script Processor"); const var scriptProcessors = []; for (id in processorIds) scriptProcessors.push(Synth.getMidiProcessor(id)); //Get processor addtribute Ids const var processorAttributes = {}; for (s in scriptProcessors) //Each processor { processorAttributes[s.getId()] = []; //Create array to store attribute IDs for (i = 0; i < s.getNumAttributes(); i++) //Each attribute processorAttributes[s.getId()].push(s.getAttributeId(i)); }
- 
 I found this getAttributeIdfunction so useful that I've added one for every scripting element that has agetAttributefunction. :)
- 
 @d-healey You rock  
 Now we have a new dev, there will be no time between Hise 3 and Hise 4... 
- 
 @d-healey Wow, this is a game changer for big projects. Super helpful! 


