Can I set info to a JSON from the onInit script?
-
I am trying to make the preset browser resize based on the main interface size, but to do that properly I need to write to the JSON file. Can that be done through onInit?
-
@VirtualVirgin what json file?
-
@d-healey This one:
Or maybe I can just set all of those properties with ".set"?
-
@VirtualVirgin Ah I understand now. So you can get the contents of the data property using .get("Data"). You can convert it to an object using .parseAsJSON(). Once it's an object it's easy to edit. Then you can turn the edited object back to a string using .trace(), and assign it to the data property using .set()
-
@d-healey I'm trying a test just to set the properties:
PresetBrowser.set("MoreButtonBounds", ["300", "15", "30", "15"]);
and I get an error:
! PresetBrowser.js (8): the property doesn't exist
Am I formatting the data wrong?
Is it expecting an array with strings like that? -
@VirtualVirgin There isn't a MoreButtonBounds property as such. The property is called Data and it contains a JSON string. As I explained above you need to grab the Data string, convert it to an object, make your changes, convert it back to a string, and reassign it to the preset browser.
You could also skip out the conversions and just work on the string directly, but this is messy.
Here's an example.
HiseSnippet 1222.3ocsV0saaaCElxIJXQ6mtBrG.BeybFLbsiccR1P2Rbbbm2pSLhy5FPQQAsDsEWjIEHoRpQQeG1c64XuBC6AZ2sKyNTR1xxwKMw.SWj3ye77wOd34v9RgKUoDRjkyESCoHqOwdvTt1+XeBii51FY8Y18HJMUhST0ZZHQondHKqMdtQg01ahh+96uqEIfvcoYpPnWJXtzWvlvzYZ6e3OxBB5P7nWvlrf2MNrqqferHPDA3YC6pnPh6kjwzSIF2JXi9dhxGY8U1UeZSJcu5i77H0q60rYyC1+fFGTiLpZCxvZMOnwtM1a282aDxZqS7XZgbflnoJXQaI7lNvWbMOIAujoXCCnFgZnAPlSTiN1mE30eF4nPHqM6mQUajPUegcOlGat9LJ6yiMfyhXQRypvcAoZO.HYs.j1LARO1dfqjEpyrXvyGa2kCmfiHvYyhPIwWTgeuf8wBvCttxDxkzNRPXdDkZVsZYL7mc9FGmm7D7yoZrjNhJovQMVKvZeJNTRUf9gRw0JpzANFUZ7UDItSffnY7wWvBn0vOCOKOio5iESBEbPnTwbdUbVhjjgwKtGQSfLHBoR8zx3q8Yt9XlBSvJsDhpLlv8vPNuBbvfHB9GFb1oXwvek5pSAS7h7r73wfhREaCVJtSkPhTQORYhrjAA.RUh.ZkPHE5RZogJLKxNovqGvT3oPoJ10mvGSUy3h3Lkj6JNFgJ8DRZqHsVvaIh3dpWU80.TplrNWDI4KGGdHT3ig7JluIi2iRJb1wFyWMs+kJb6EoJm7aV07MaYbtsynHtqlI3XA+TgldFuzNNuyYam26fW1znQqzl4TUJBBnxUZ1bMWdWAVhGMYHUVFJYBhnycDJqyeWYq62cE2jhrEbTv6xY5yBooxcDAdl6.lee6aVnzpT3W+TWCiYtrkpqeB4xLvwpM8Jn8VxUussaSUWpEgw9lVZC28zo8JRtrs3QBhAH3Q14NkPucw9gSyD91Cul4ogte1VUKfP9T1XesQ5Osli2Df7H69wkEsRpJPCGOqk51aAKz+XVMllNIS6ebyucSds6l5b7WLCT3uJX+NGLtngUGPtJsft3WC0RQzxyrbxaCIbEb3pNRAKUzDiGiHApLWh4d4pC2Tjot0ZB0.ItmyTlZnrD1ufsZUmGzQddqNEmS4v3jUaqMMfp+OrMfRjt9sHxkMzgbkPBTmY30h15DEDzmn8mYWkiIR2PcAxxi1RHAJIm8SiljvelvpGqJQ9mMkAmCULBvvq.8Xb0J0W5q7CTOn90w43ELk9HnMybJMMCkW0+lGUBxNWbcehmGTJeeiaNmlzWzDVhgk6XlsfYwNuFb4fmQ32xpy6gGebqYlvzZgWT.QmeDt4wMoFfx4byMMyFgyM8zEe7yCXtd06bt98EhO1tOS65uZLVXEXD5h8+AFSeMzmZexnQvrqL.tocmeYce5yGH8mKhLsL6QfYiPGSa31x.nskKExNmSCTlNiELcxSjqZjMLv.J2KV3F3K0XMirUpwZyLhlPbkh23lLgx7dqOJVCfId76Q2FdXLHiqghmZsHOOAd92abcyuT2JvcW2.qutA1XcC7oqafMW2.2acCb+ObflWmeTjVLI4ZCB0q+IwC4rrNgSfJv3pUz+BAyAuhA
-
@d-healey
Thanks! I got it working from your snippet.
The preset browser now resizes nicely if I change the interface size.