HISE Logo Forum
    • Categories
    • Register
    • Login

    Save Multiple Custom Plugin Settings

    Scheduled Pinned Locked Moved General Questions
    4 Posts 2 Posters 175 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DanHD
      DanH
      last edited by

      In my project I'm using the below code (as an example) to save a global plugin setting. I'd like to add a few other settings to the file rather than create a new JSON for each setting but it seems the dumpAsJSON function only allows one argument, so what's the best way to achieve this?

      if(Engine.loadFromJSON("..//MySettings.js") == undefined)
      {
             
          SETTING1.setValue(0);
          SETTING1.changed();
          
          Engine.dumpAsJSON({"setting1": 1}, "..//MySettings.js");
      
      }
      
      inline function onSETTING1Control(component, value)
      {
          Panel1.showControl(value);
      
          Engine.dumpAsJSON({"setting1":value}, "..//MySettings.js");
          
      };
      
      Content.getComponent("SETTING1").setControlCallback(onSETTING1Control);
      

      DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
      https://dhplugins.com/ | https://dcbreaks.com/
      London, UK

      1 Reply Last reply Reply Quote 0
      • LindonL
        Lindon
        last edited by

        err ... you can have as many "arguments" in a JSON file as you like...

        if(Engine.loadFromJSON("..//MySettings.js") == undefined)
        {
               
            SETTING1.setValue(0);
            SETTING1.changed();
            SETTING2.setValue("hello");
            SETTING3.setValue(27);    
            Engine.dumpAsJSON({"setting1": 1,"setting2": "Hello", "setting3":27 }, "..//MySettings.js");
        
        }
        

        HISE Development for hire.
        www.channelrobot.com

        LindonL 1 Reply Last reply Reply Quote 0
        • LindonL
          Lindon @Lindon
          last edited by Lindon

          though you are probably better off doing it this way:

          reg myJSONObj = Engine.loadFromJSON("..//MySettings.js") ;
          if(myJSONObj == "")
          {
              myJSONObj = {
                       "setting1": 1,
                        "setting2": "Hello",
                        "setting3":27 
                         };
               Engine.dumpAsJSON(myJSONObj , "..//MySettings.js");
          };
          
          inline function onSETTING1Control(component, value)
          {
              Panel1.showControl(value);
              myJSONObj.setting1 = value;
              Engine.dumpAsJSON(myJSONObj, "..//MySettings.js");
              
          };
          

          HISE Development for hire.
          www.channelrobot.com

          DanHD 1 Reply Last reply Reply Quote 1
          • DanHD
            DanH @Lindon
            last edited by

            @Lindon ah I was trying it with parenthesis, thanks!

            DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
            https://dhplugins.com/ | https://dcbreaks.com/
            London, UK

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            32

            Online

            1.8k

            Users

            12.0k

            Topics

            104.2k

            Posts